SendMessage WM_MOUSEMOVE 未按预期工作
当将 WM_MOUSEMOVE 消息发送到应用程序(在本例中为 Open Office Writer)的客户区时,图像将闪烁,就好像鼠标位于指定坐标上一样,但不会停留在该状态。代码为:
PostMessage(hWndClient, WM_MOUSEMOVE, 0, MAKEWORD(x, y))
其中 x 和 y 相对于客户区。
循环发送它仍然不起作用,因为鼠标悬停事件突出显示的区域只会闪烁。
任何帮助将不胜感激。
When sending the WM_MOUSEMOVE message to the client area of an application (in this case Open Office Writer) the image will flicker as if the mouse is over the specified coordinates, but does not stay in that state. The code is:
PostMessage(hWndClient, WM_MOUSEMOVE, 0, MAKEWORD(x, y))
where x and y are relative to the client area.
Sending this in a loop still does not work as the area highlighted by the mouse over event will just flicker.
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
该应用程序可能会触发各种其他事件。也许它想看到 WM_MOUSEHOVER 等...已经有一段时间了,但我记得其中一些事件的实现方式确实很混乱 - 就像有一个单独的线程轮询鼠标并在鼠标移动时生成 WM_MOUSELEAVE 事件不再在窗户上方。你也可能被类似的东西咬伤。应用程序本身也可能在收到事件时轮询鼠标的真实位置。
根据您想要执行的操作,也许您可以通过编程方式移动鼠标,而不仅仅是尝试伪造事件。不幸的是,我不记得这个的API,但我确信这是可能的。
The app could be triggering on all sorts of other events. Maybe it wants to see WM_MOUSEHOVER etc... It's been long a while, but I remember there being something really klugy about how some of these events were implemented - like there was a separate thread that polled the mouse and generated WM_MOUSELEAVE events when the mouse was no longer over the window. You could be getting bitten by something like that too. It's also possible that the application itself is polling the mouse for its true position when it receives the event.
Depending on what you're trying to do, perhaps you could programmatically move the mouse instead of just trying to fake events. Unfortunately, I don't remember the API for this, but I'm sure it's possible.
我在我的主窗口中使用了这样的东西,看起来有帮助......在 WM_MOUSEMOVE 中:
I used sth like this in my main window and looks that helps... in WM_MOUSEMOVE:
试试这个:
PostMessage(hWndClient, WM_MOUSEMOVE, MK_LBUTTON, MAKELONG(x, y))
,由于postion是一个32位整数,低16位是x,高16位是y,也许你应该使用MAKELONG
而不是MAKEWORD
。检查WM_MOUSEMOVE。
Try this:
PostMessage(hWndClient, WM_MOUSEMOVE, MK_LBUTTON, MAKELONG(x, y))
, since postion is a 32-bit integer, the lower 16 bit is x, and the higher 16 bit is y, maybe you should useMAKELONG
instead ofMAKEWORD
.Check WM_MOUSEMOVE.