mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-17 13:33:55 +00:00
Compare commits
4 Commits
ddb5272038
...
8ac68def76
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8ac68def76 | ||
![]() |
03432155c1 | ||
![]() |
6a1f060a8c | ||
![]() |
be5a13d7b3 |
@ -96,25 +96,7 @@ void moveMouse(MMPointInt32 point){
|
|||||||
|
|
||||||
XSync(display, false);
|
XSync(display, false);
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
// Mouse motion is now done using SendInput with MOUSEINPUT.
|
SetCursorPos(point.x, point.y);
|
||||||
// We use Absolute mouse positioning
|
|
||||||
#define MOUSE_COORD_TO_ABS(coord, width_or_height) ( \
|
|
||||||
((65536 * coord) / width_or_height) + (coord < 0 ? -1 : 1))
|
|
||||||
|
|
||||||
MMRectInt32 rect = getScreenRect(1);
|
|
||||||
int32_t x = MOUSE_COORD_TO_ABS(point.x - rect.origin.x, rect.size.w);
|
|
||||||
int32_t y = MOUSE_COORD_TO_ABS(point.y - rect.origin.y, rect.size.h);
|
|
||||||
|
|
||||||
INPUT mouseInput;
|
|
||||||
mouseInput.type = INPUT_MOUSE;
|
|
||||||
mouseInput.mi.dx = x;
|
|
||||||
mouseInput.mi.dy = y;
|
|
||||||
mouseInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_VIRTUALDESK;
|
|
||||||
mouseInput.mi.time = 0; // System will provide the timestamp
|
|
||||||
|
|
||||||
mouseInput.mi.dwExtraInfo = 0;
|
|
||||||
mouseInput.mi.mouseData = 0;
|
|
||||||
SendInput(1, &mouseInput, sizeof(mouseInput));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,12 +76,25 @@ MMSizeInt32 getMainDisplaySize(void) {
|
|||||||
CGSize size = displayRect.size;
|
CGSize size = displayRect.size;
|
||||||
return MMSizeInt32Make((int32_t)size.width, (int32_t)size.height);
|
return MMSizeInt32Make((int32_t)size.width, (int32_t)size.height);
|
||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
Display *display = XGetMainDisplay();
|
// Display *display = XGetMainDisplay();
|
||||||
const int screen = DefaultScreen(display);
|
// const int screen = DefaultScreen(display);
|
||||||
|
|
||||||
return MMSizeInt32Make(
|
// return MMSizeInt32Make(
|
||||||
(int32_t)DisplayWidth(display, screen),
|
// (int32_t)DisplayWidth(display, screen),
|
||||||
(int32_t)DisplayHeight(display, screen));
|
// (int32_t)DisplayHeight(display, screen));
|
||||||
|
Display *display = XOpenDisplay(NULL);
|
||||||
|
if (display == NULL) {
|
||||||
|
return MMSizeInt32Make(0, 0); // Return an invalid size if unable to open display
|
||||||
|
}
|
||||||
|
|
||||||
|
const int screen = DefaultScreen(display);
|
||||||
|
MMSizeInt32 resolution = MMSizeInt32Make(
|
||||||
|
(int32_t)DisplayWidth(display, screen),
|
||||||
|
(int32_t)DisplayHeight(display, screen)
|
||||||
|
);
|
||||||
|
|
||||||
|
XCloseDisplay(display);
|
||||||
|
return resolution;
|
||||||
#elif defined(IS_WINDOWS)
|
#elif defined(IS_WINDOWS)
|
||||||
return MMSizeInt32Make(
|
return MMSizeInt32Make(
|
||||||
(int32_t)GetSystemMetrics(SM_CXSCREEN),
|
(int32_t)GetSystemMetrics(SM_CXSCREEN),
|
||||||
|
Loading…
Reference in New Issue
Block a user