mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
Update CaptureScreen
This commit is contained in:
parent
3deaefc81b
commit
239c29810b
26
robotgo.go
26
robotgo.go
@ -74,13 +74,33 @@ func SetXDisplayName(name string) string {
|
||||
return gstr
|
||||
}
|
||||
|
||||
func CaptureScreen(x, y, w, h C.int) C.MMBitmapRef {
|
||||
func CaptureScreen(args ...int) C.MMBitmapRef {
|
||||
var x C.size_t
|
||||
var y C.size_t
|
||||
var w C.size_t
|
||||
var h C.size_t
|
||||
Try(func() {
|
||||
x = C.size_t(args[1])
|
||||
y = C.size_t(args[2])
|
||||
w = C.size_t(args[3])
|
||||
h = C.size_t(args[4])
|
||||
}, func(e interface{}) {
|
||||
// Println("err:::", e)
|
||||
x = 0
|
||||
y = 0
|
||||
//Get screen size.
|
||||
var displaySize C.MMSize
|
||||
displaySize = C.getMainDisplaySize()
|
||||
w = displaySize.width
|
||||
h = displaySize.height
|
||||
})
|
||||
|
||||
bit := C.aCaptureScreen(x, y, w, h)
|
||||
Println("...", bit.width)
|
||||
// Println("...", bit.width)
|
||||
return bit
|
||||
}
|
||||
|
||||
func Capture_Screen(x, y, w, h C.int) Bit_map {
|
||||
func Capture_Screen(x, y, w, h C.size_t) Bit_map {
|
||||
bit := C.aCaptureScreen(x, y, w, h)
|
||||
// Println("...", bit)
|
||||
bit_map := Bit_map{
|
||||
|
@ -67,7 +67,7 @@ char* aSetXDisplayName(char* name){
|
||||
#endif
|
||||
}
|
||||
|
||||
MMBitmapRef aCaptureScreen(int x,int y,int w,int h){
|
||||
MMBitmapRef aCaptureScreen(size_t x,size_t y,size_t w,size_t h){
|
||||
// if (){
|
||||
// x = 0;
|
||||
// y = 0;
|
||||
|
@ -32,6 +32,9 @@ func arobotgo() {
|
||||
// robotgo.KeyToggle("enter", "down")
|
||||
robotgo.TypeString("en")
|
||||
|
||||
abit_map := robotgo.CaptureScreen()
|
||||
Println("all...", abit_map)
|
||||
|
||||
bit_map := robotgo.CaptureScreen(10, 20, 30, 40)
|
||||
Println("...", bit_map)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user