Fix MouseToggle

This commit is contained in:
vCaesar 2016-10-24 14:28:58 +08:00
parent a5a084333b
commit 404d16f9fc
2 changed files with 22 additions and 5 deletions

View File

@ -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;
} }

View File

@ -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) {