英文:
Mouse click/move simulation on a "specific window"
问题
这是我代码的一部分,用于实现鼠标模拟:
SendMessage(winHandle, WM_MOUSEMOVE, 0, MAKELPARAM(0, 0));
SendMessage(winHandle, WM_LBUTTONDOWN, 0, 0);
SendMessage(winHandle, WM_LBUTTONUP, 0, 0);
正如你所见,我试图让鼠标光标移动到指定窗口的坐标点 (0, 0) 并执行一次点击。但出于某种原因,光标根本不动,而只是在当前位置进行点击。我该如何解决这个问题?
英文:
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?
答案1
得分: 2
WM_MOUSEMOVE
实际上不会移动光标,它只是通知窗口发生了移动。要实际移动光标,请使用SetCursorPos()
或SendInput()
。可以使用ClientToScreen()
或MapWindowPoints()
将所需的客户端坐标转换为屏幕坐标,然后进行移动。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论