mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-06 08:43:56 +00:00
Merge pull request #175 from go-vgo/dev
use sendInput not keybd_event & mouse_event
This commit is contained in:
commit
48a33f8a6d
@ -103,7 +103,17 @@ void win32KeyEvent(int key, MMKeyFlags flags){
|
|||||||
// scan |= 0x80;
|
// scan |= 0x80;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
keybd_event(key, scan, flags, 0);
|
// keybd_event(key, scan, flags, 0);
|
||||||
|
|
||||||
|
INPUT keyInput;
|
||||||
|
|
||||||
|
keyInput.type = INPUT_KEYBOARD;
|
||||||
|
keyInput.ki.wVk = key;
|
||||||
|
keyInput.ki.wScan = scan;
|
||||||
|
keyInput.ki.dwFlags = flags;
|
||||||
|
keyInput.ki.time = 0;
|
||||||
|
keyInput.ki.dwExtraInfo = 0;
|
||||||
|
SendInput(1, &keyInput, sizeof(keyInput));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ void toggleMouse(bool down, MMMouseButton button){
|
|||||||
const CGPoint currentPos = CGPointFromMMPoint(getMousePos());
|
const CGPoint currentPos = CGPointFromMMPoint(getMousePos());
|
||||||
const CGEventType mouseType = MMMouseToCGEventType(down, button);
|
const CGEventType mouseType = MMMouseToCGEventType(down, button);
|
||||||
CGEventRef event = CGEventCreateMouseEvent(NULL,
|
CGEventRef event = CGEventCreateMouseEvent(NULL,
|
||||||
mouseType, currentPos, (CGMouseButton)button);
|
mouseType, currentPos, (CGMouseButton)button);
|
||||||
|
|
||||||
CGEventPost(kCGSessionEventTap, event);
|
CGEventPost(kCGSessionEventTap, event);
|
||||||
CFRelease(event);
|
CFRelease(event);
|
||||||
@ -189,7 +189,18 @@ void toggleMouse(bool down, MMMouseButton button){
|
|||||||
XTestFakeButtonEvent(display, button, down ? True : False, CurrentTime);
|
XTestFakeButtonEvent(display, button, down ? True : False, CurrentTime);
|
||||||
XSync(display, false);
|
XSync(display, false);
|
||||||
#elif defined(IS_WINDOWS)
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +272,9 @@ void scrollMouse(int scrollMagnitude, MMMouseWheelDirection scrollDirection){
|
|||||||
/* Make scroll magnitude negative if we're scrolling down. */
|
/* Make scroll magnitude negative if we're scrolling down. */
|
||||||
cleanScrollMagnitude = cleanScrollMagnitude * scrollDirection;
|
cleanScrollMagnitude = cleanScrollMagnitude * scrollDirection;
|
||||||
|
|
||||||
event = CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitLine, wheel, cleanScrollMagnitude, 0);
|
event = CGEventCreateScrollWheelEvent(NULL,
|
||||||
|
kCGScrollEventUnitLine, wheel, cleanScrollMagnitude, 0);
|
||||||
|
|
||||||
CGEventPost(kCGHIDEventTap, event);
|
CGEventPost(kCGHIDEventTap, event);
|
||||||
|
|
||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
|
Loading…
Reference in New Issue
Block a user