mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
use sendInput not mouse_event and update code style
This commit is contained in:
parent
3291faad53
commit
323eed683d
@ -180,8 +180,8 @@ void toggleMouse(bool down, MMMouseButton button){
|
||||
const CGPoint currentPos = CGPointFromMMPoint(getMousePos());
|
||||
const CGEventType mouseType = MMMouseToCGEventType(down, button);
|
||||
CGEventRef event = CGEventCreateMouseEvent(NULL,
|
||||
mouseType, currentPos, (CGMouseButton)button);
|
||||
|
||||
mouseType, currentPos, (CGMouseButton)button);
|
||||
|
||||
CGEventPost(kCGSessionEventTap, event);
|
||||
CFRelease(event);
|
||||
#elif defined(USE_X11)
|
||||
@ -189,7 +189,18 @@ void toggleMouse(bool down, MMMouseButton button){
|
||||
XTestFakeButtonEvent(display, button, down ? True : False, CurrentTime);
|
||||
XSync(display, false);
|
||||
#elif defined(IS_WINDOWS)
|
||||
mouse_event(MMMouseToMEventF(down, button), 0, 0, 0, 0);
|
||||
// mouse_event(MMMouseToMEventF(down, button), 0, 0, 0, 0);
|
||||
|
||||
INPUT mouseInput;
|
||||
|
||||
mouseInput.type = INPUT_MOUSE;
|
||||
mouseInput.mi.dx = 0;
|
||||
mouseInput.mi.dy = 0;
|
||||
mouseInput.mi.dwFlags = MMMouseToMEventF(down, button);
|
||||
mouseInput.mi.time = 0;
|
||||
mouseInput.mi.dwExtraInfo = 0;
|
||||
mouseInput.mi.mouseData = 0;
|
||||
SendInput(1, &mouseInput, sizeof(mouseInput));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -261,7 +272,9 @@ void scrollMouse(int scrollMagnitude, MMMouseWheelDirection scrollDirection){
|
||||
/* Make scroll magnitude negative if we're scrolling down. */
|
||||
cleanScrollMagnitude = cleanScrollMagnitude * scrollDirection;
|
||||
|
||||
event = CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitLine, wheel, cleanScrollMagnitude, 0);
|
||||
event = CGEventCreateScrollWheelEvent(NULL,
|
||||
kCGScrollEventUnitLine, wheel, cleanScrollMagnitude, 0);
|
||||
|
||||
CGEventPost(kCGHIDEventTap, event);
|
||||
|
||||
#elif defined(USE_X11)
|
||||
|
Loading…
Reference in New Issue
Block a user