Home > Back-end >  Mouse click/move simulation on a "specific window"
Mouse click/move simulation on a "specific window"

Time:01-09

This is the part of my code that is supposed to implement the mouse simulation:

SendMessage(winHandle, WM_MOUSEMOVE, 0, MAKELPARAM(0, 0));
SendMessage(winHandle, WM_LBUTTONDOWN, 0, 0);
SendMessage(winHandle, WM_LBUTTONUP, 0, 0);

As you can see, i'm trying to make the mouse's cursor move to a the point (0, 0) of the specified window and perform a single click. But for some reason, the cursor doesn't move at all, and it just clicks on wherever it's currently in. How can i fix that?

CodePudding user response:

WM_MOUSEMOVE doesn't actually move the cursor, it just notifies the window that a movement had occurred. To actually move the cursor, use SetCursorPos() or SendInput() instead. Use ClientToScreen() or MapWindowPoints() to convert the desired client coordinates into screen coordinates to then move to.

  • Related