From a93a984215e121e33c3dfa6946865d7c72993398 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Mon, 3 Jan 2022 21:56:14 -0400 Subject: [PATCH] add move mouse windows multi screen support --- mouse/mouse_c.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mouse/mouse_c.h b/mouse/mouse_c.h index 1b72e74..ce4595e 100644 --- a/mouse/mouse_c.h +++ b/mouse/mouse_c.h @@ -113,14 +113,15 @@ void moveMouse(MMPointInt32 point){ #define MOUSE_COORD_TO_ABS(coord, width_or_height) ( \ ((65536 * coord) / width_or_height) + (coord < 0 ? -1 : 1)) - point.x = MOUSE_COORD_TO_ABS(point.x, GetSystemMetrics(SM_CXSCREEN)); - point.y = MOUSE_COORD_TO_ABS(point.y, GetSystemMetrics(SM_CYSCREEN)); + MMRectInt32 rect = getScreenRect(); + size_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); INPUT mouseInput; mouseInput.type = INPUT_MOUSE; - mouseInput.mi.dx = point.x; - mouseInput.mi.dy = point.y; - mouseInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE; + 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;