Skip to content

Commit 66611b7

Browse files
Deltatigeroctalmage
authored andcommitted
Migrate to SendInput from mouse_event (#181)
* Test fix for node 0.8 failing. This was suggested by someone. Just checking it out. * Migrate to SendInput for Mouse movement Since mouse_event is deprecated we are moving to SendInput. * Revert "Test fix for node 0.8 failing." This reverts commit eb18a1f.
1 parent 4d003a5 commit 66611b7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/mouse.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,20 @@ void moveMouse(MMPoint point)
105105
0, 0, 0, 0, point.x, point.y);
106106
XFlush(display);
107107
#elif defined(IS_WINDOWS)
108+
//Mouse motion is now done using SendInput with MOUSEINPUT. We use Absolute mouse positioning
108109
#define MOUSE_COORD_TO_ABS(coord, width_or_height) (((65536 * coord) / width_or_height) + (coord < 0 ? -1 : 1))
109110
point.x = MOUSE_COORD_TO_ABS(point.x, GetSystemMetrics(SM_CXSCREEN));
110111
point.y = MOUSE_COORD_TO_ABS(point.y, GetSystemMetrics(SM_CYSCREEN));
111-
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE,
112-
(DWORD)point.x, (DWORD)point.y, 0, 0);
112+
INPUT mouseInput;
113+
mouseInput.type = INPUT_MOUSE;
114+
mouseInput.mi.dx = point.x;
115+
mouseInput.mi.dy = point.y;
116+
mouseInput.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
117+
mouseInput.mi.time = 0; //System will provide the timestamp
118+
mouseInput.mi.dwExtraInfo = 0;
119+
mouseInput.mi.mouseData = 0;
120+
SendInput(1, &mouseInput, sizeof(mouseInput));
121+
113122
#endif
114123
}
115124

0 commit comments

Comments
 (0)