如何在 Delphi 中使用 SendInput?
我在 Delphi 2009 中使用 Mouse_Event
函数,但 Delphi 文档说该函数已被取代并使用 SendInput
代替。
Delphi SendInput
文档定义了语法和参数,但没有示例,也不清楚如何使用该函数。我在网上查了一下,没有找到任何好的 Delphi 示例。
具体来说,我试图模拟鼠标左键向下然后向上。目前,我使用 Mouse_Event
执行此操作,如下所示:
Mouse_Event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
Mouse_Event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
我将如何使用 SendInput
执行此操作?
后续:
我最终按照@David的建议保留了我的代码。
但我给了@opc0de 答案,因为他确实回答了我的问题。但是,我不能保证它是正确的,因为我从未尝试过。
I was using the Mouse_Event
Function in Delphi 2009, but the Delphi documentation says this function has been superceded and to use SendInput
instead.
The Delphi SendInput
documentation defines the syntax and parameters, but there are no examples and it is not clear how to use the function. I've looked around on the web, and can't find any good Delphi examples.
Specifically, I am trying to simulate the left mouse down and then up. Currently I do this with Mouse_Event
as follows:
Mouse_Event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
Mouse_Event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
How would I do this using SendInput
?
Followup:
I ended up leaving my code as is as @David suggested.
But I gave @opc0de the answer since he did give an answer to my question. However, I can't vouch that it is correct, because I never did try it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是如何模拟左键单击,有关更多详细信息,请访问 http://msdn.microsoft .com/en-us/library/ms646310(VS.85).aspx
这里用于模拟右键单击
Here is how to simulate a left click for more details visit http://msdn.microsoft.com/en-us/library/ms646310(VS.85).aspx
And here is for simulating right click