mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-02 23:23:55 +00:00
Fix MouseToggle
This commit is contained in:
parent
a5a084333b
commit
404d16f9fc
@ -86,10 +86,19 @@ int aMouseClick(){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int aMouseToggle(){
|
int aMouseToggle(char* d,MMMouseButton button){
|
||||||
MMMouseButton button = LEFT_BUTTON;
|
// MMMouseButton button = LEFT_BUTTON;
|
||||||
bool down = false;
|
bool down = false;
|
||||||
|
if (strcmp(d, "down") == 0){
|
||||||
|
down = true;
|
||||||
|
}else if (strcmp(d, "up") == 0){
|
||||||
|
down = false;
|
||||||
|
}else{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleMouse(down, button);
|
||||||
|
microsleep(mouseDelay);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
robotgo.go
14
robotgo.go
@ -6,7 +6,7 @@ package robotgo
|
|||||||
#cgo darwin LDFLAGS: -framework Cocoa -framework OpenGL -framework IOKit -framework Carbon -framework CoreFoundation
|
#cgo darwin LDFLAGS: -framework Cocoa -framework OpenGL -framework IOKit -framework Carbon -framework CoreFoundation
|
||||||
//#elif defined(USE_X11)
|
//#elif defined(USE_X11)
|
||||||
#cgo linux CFLAGS:-I/usr/src
|
#cgo linux CFLAGS:-I/usr/src
|
||||||
#cgo linux LDFLAGS:-L/usr/src -lX11 -lXtst -lm
|
#cgo linux LDFLAGS:-L/usr/src -lpng -lz -lX11 -lXtst -lm
|
||||||
//#endif
|
//#endif
|
||||||
#cgo windows LDFLAGS: -lgdi32 -luser32
|
#cgo windows LDFLAGS: -lgdi32 -luser32
|
||||||
//#include <AppKit/NSEvent.h>
|
//#include <AppKit/NSEvent.h>
|
||||||
@ -138,8 +138,16 @@ func MouseClick() {
|
|||||||
C.aMouseClick()
|
C.aMouseClick()
|
||||||
}
|
}
|
||||||
|
|
||||||
func MouseToggle() {
|
func MouseToggle(args ...interface{}) {
|
||||||
C.aMouseToggle()
|
var button C.MMMouseButton
|
||||||
|
Try(func() {
|
||||||
|
button = args[1].(C.MMMouseButton)
|
||||||
|
}, func(e interface{}) {
|
||||||
|
// Println("err:::", e)
|
||||||
|
button = C.LEFT_BUTTON
|
||||||
|
})
|
||||||
|
down := C.CString(args[0].(string))
|
||||||
|
C.aMouseToggle(down, button)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetMouseDelay(x int) {
|
func SetMouseDelay(x int) {
|
||||||
|
Loading…
Reference in New Issue
Block a user