mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
Update windows int type
This commit is contained in:
parent
cf237175a7
commit
7685ce8a3b
@ -93,9 +93,8 @@ void calculateDeltas(CGEventRef *event, MMPointInt32 point){
|
|||||||
*/
|
*/
|
||||||
void moveMouse(MMPointInt32 point){
|
void moveMouse(MMPointInt32 point){
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
CGEventRef move = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved,
|
CGEventRef move = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved,
|
||||||
CGPointFromMMPointInt32(point),
|
CGPointFromMMPointInt32(point), kCGMouseButtonLeft);
|
||||||
kCGMouseButtonLeft);
|
|
||||||
|
|
||||||
calculateDeltas(&move, point);
|
calculateDeltas(&move, point);
|
||||||
|
|
||||||
@ -103,8 +102,7 @@ void moveMouse(MMPointInt32 point){
|
|||||||
CFRelease(move);
|
CFRelease(move);
|
||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
Display *display = XGetMainDisplay();
|
Display *display = XGetMainDisplay();
|
||||||
XWarpPointer(display, None, DefaultRootWindow(display),
|
XWarpPointer(display, None, DefaultRootWindow(display), 0, 0, 0, 0, point.x, point.y);
|
||||||
0, 0, 0, 0, point.x, point.y);
|
|
||||||
|
|
||||||
XSync(display, false);
|
XSync(display, false);
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
@ -114,8 +112,8 @@ void moveMouse(MMPointInt32 point){
|
|||||||
((65536 * coord) / width_or_height) + (coord < 0 ? -1 : 1))
|
((65536 * coord) / width_or_height) + (coord < 0 ? -1 : 1))
|
||||||
|
|
||||||
MMRectInt32 rect = getScreenRect(-1);
|
MMRectInt32 rect = getScreenRect(-1);
|
||||||
size_t x = MOUSE_COORD_TO_ABS(point.x - rect.origin.x, rect.size.w);
|
int32_t x = MOUSE_COORD_TO_ABS(point.x - rect.origin.x, rect.size.w);
|
||||||
size_t y = MOUSE_COORD_TO_ABS(point.y - rect.origin.y, rect.size.h);
|
int32_t y = MOUSE_COORD_TO_ABS(point.y - rect.origin.y, rect.size.h);
|
||||||
|
|
||||||
INPUT mouseInput;
|
INPUT mouseInput;
|
||||||
mouseInput.type = INPUT_MOUSE;
|
mouseInput.type = INPUT_MOUSE;
|
||||||
@ -123,6 +121,7 @@ void moveMouse(MMPointInt32 point){
|
|||||||
mouseInput.mi.dy = y;
|
mouseInput.mi.dy = y;
|
||||||
mouseInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_VIRTUALDESK;
|
mouseInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_VIRTUALDESK;
|
||||||
mouseInput.mi.time = 0; // System will provide the timestamp
|
mouseInput.mi.time = 0; // System will provide the timestamp
|
||||||
|
|
||||||
mouseInput.mi.dwExtraInfo = 0;
|
mouseInput.mi.dwExtraInfo = 0;
|
||||||
mouseInput.mi.mouseData = 0;
|
mouseInput.mi.mouseData = 0;
|
||||||
SendInput(1, &mouseInput, sizeof(mouseInput));
|
SendInput(1, &mouseInput, sizeof(mouseInput));
|
||||||
@ -133,8 +132,8 @@ void moveMouse(MMPointInt32 point){
|
|||||||
void dragMouse(MMPointInt32 point, const MMMouseButton button){
|
void dragMouse(MMPointInt32 point, const MMMouseButton button){
|
||||||
#if defined(IS_MACOSX)
|
#if defined(IS_MACOSX)
|
||||||
const CGEventType dragType = MMMouseDragToCGEventType(button);
|
const CGEventType dragType = MMMouseDragToCGEventType(button);
|
||||||
CGEventRef drag = CGEventCreateMouseEvent(NULL, dragType,
|
CGEventRef drag = CGEventCreateMouseEvent(NULL, dragType,
|
||||||
CGPointFromMMPoint(point), (CGMouseButton)button);
|
CGPointFromMMPoint(point), (CGMouseButton)button);
|
||||||
|
|
||||||
calculateDeltas(&drag, point);
|
calculateDeltas(&drag, point);
|
||||||
|
|
||||||
@ -181,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);
|
||||||
@ -191,7 +190,6 @@ void toggleMouse(bool down, MMMouseButton button){
|
|||||||
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;
|
INPUT mouseInput;
|
||||||
|
|
||||||
mouseInput.type = INPUT_MOUSE;
|
mouseInput.type = INPUT_MOUSE;
|
||||||
@ -224,7 +222,7 @@ void doubleClick(MMMouseButton button){
|
|||||||
const CGEventType mouseTypeUP = MMMouseToCGEventType(false, button);
|
const CGEventType mouseTypeUP = MMMouseToCGEventType(false, button);
|
||||||
|
|
||||||
CGEventRef event = CGEventCreateMouseEvent(
|
CGEventRef event = CGEventCreateMouseEvent(
|
||||||
NULL, mouseTypeDown, currentPos, kCGMouseButtonLeft);
|
NULL, mouseTypeDown, currentPos, kCGMouseButtonLeft);
|
||||||
|
|
||||||
/* Set event to double click. */
|
/* Set event to double click. */
|
||||||
CGEventSetIntegerValueField(event, kCGMouseEventClickState, 2);
|
CGEventSetIntegerValueField(event, kCGMouseEventClickState, 2);
|
||||||
@ -275,7 +273,7 @@ void scrollMouse(int scrollMagnitude, MMMouseWheelDirection scrollDirection){
|
|||||||
cleanScrollMagnitude = cleanScrollMagnitude * scrollDirection;
|
cleanScrollMagnitude = cleanScrollMagnitude * scrollDirection;
|
||||||
|
|
||||||
event = CGEventCreateScrollWheelEvent(NULL,
|
event = CGEventCreateScrollWheelEvent(NULL,
|
||||||
kCGScrollEventUnitLine, wheel, cleanScrollMagnitude, 0);
|
kCGScrollEventUnitLine, wheel, cleanScrollMagnitude, 0);
|
||||||
|
|
||||||
CGEventPost(kCGHIDEventTap, event);
|
CGEventPost(kCGHIDEventTap, event);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user