Reputation: 406
I want to make my program click specific mouse coordinates, so I am using
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN, point.x, point.y, 0, 0);
where point.x and point.y are normalized between 0 and 65535. However, it always clicks where the cursor is instead of the coordinates that I pass. Why is that happening?
Upvotes: 4
Views: 6678
Reputation: 9796
simulate all the mouse events
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, point.x, point.y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
Upvotes: 6
Reputation: 3189
You might be missing MOUSEEVENTF_MOVE
flag.
If that doesn't work - I suggest you just use SetCursorPos()
to set the location. Then your mouse_move
event should work just fine.
Upvotes: 6