使用 SendMessage 模拟用户鼠标点击
我需要使用 SendMessage 来模拟用户在目标程序中的点击,因为 SendMessage 会阻塞,直到它触发的事件完成处理为止。 这样做的原因是,此阻止提供了检测是否因单击而打开任何对话框的机会。 我目前的问题是,虽然我可以在打开模型对话框的模拟表单中的按钮上连续使用 WM_LBUTTONDOWN 和 WM_LBUTTONUP 消息进行单击,但我无法让它在标准 Windows 应用程序中的菜单和菜单项上工作(记事本)。 任何有助于以有效的方式执行菜单项单击的能力的帮助将不胜感激。 我已经可以检测它是否是一个菜单项,只需要能够使用 SendMessage 阻塞来模拟单击它。
干杯
罗斯
I need to use SendMessage fro simulating user clicks in a target program as SendMessage blocks until the event that it triggers is finished processing. The reason for this is that this blocking gives opportunity to detect if any dialogs have opened up as a result of the clicking. My problem currently is that although I can get the click to work using WM_LBUTTONDOWN and WM_LBUTTONUP messages consecutivly on a button in a mocked up form which opens a model dialog, I cannot get it to work on menus and menu items in a standard windows app (Notepad). Any help in getting the ability to perform clicks on menu items in a way which works would be apprecieated. I can already detect if it is a menu item, just need to be able to simulate a click on it with blocking using SendMessage.
Cheers
Ross
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,win32 hooks 上的此页面说
因此,您似乎必须使用 WH_JOURNALRECORD 和 WH_JOURNALPLAYBACK 来借助某种类似宏记录器的功能来进行自动化测试?
Unfortunately, this page on win32 hooks says
So it looks like you may have to resort to some kind of macro recorder-like functionality for your automated testing by using
WH_JOURNALRECORD
andWH_JOURNALPLAYBACK
?