C# InputSimulator 包装器 - 如何使用它?
我想模拟外部程序的键盘点击。我尝试过SendMessage、PostMessage、SendKeys,但它们不会将密钥发送到某个特定程序。所以我想尝试 SendInput 并且我已经下载了一个很好的包装器 SendInput - http://inputsimulator.codeplex.com/
我已添加程序集到我的项目中,但我还无法开始使用任何功能...
我必须做什么? 我应该添加什么“使用”?
I want to simulate keyboard click for a external program.I've tried SendMessage, PostMessage, SendKeys but they do not send the key to one specific program. So i wanted to try SendInput and i have downloaded a good wrapper for SendInput - http://inputsimulator.codeplex.com/
i have added the assembly to my project but i cannot yet start using any of the functions...
What i have to do?
What "Using" should i add?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我相信您需要一个
如果不是这样,您可以在对象浏览器中查看它并查看名称空间。只需右键单击解决方案资源管理器中的引用,然后单击“浏览”。
I believe you need a
If that's not it, you can view it in the Object Browser and see the namespace. Just right click the reference in solution explorer and click browse.
您可以像这样模拟程序的键盘输入:
使用SendKeys.SendWait 方法发送实际密钥到程序窗口
示例代码(测试前启动记事本):
You can simulate keyboard input to a program like this:
bring the program you want to send keys to the foreground using SetForegroundWindow from user32.dll
use the SendKeys.SendWait Method to send the actual key to the program window
Example code (launch notepad before testing):
我遇到了同样的问题,但我设法通过以下 3 个步骤来做到这一点
将 InputSimulator 内容提取到像您这样的合理位置
项目 URL
在 Visual Studio 中单击“项目”->“添加引用”并浏览到
InputSimulator DLL 文件
Windows输入法;”
I had the same problem but i managed to do it by following these 3 steps
Extract the InputSimulator contents somewhere sensible like your
project URL
In Visual Studio Click Project->Add Reference and browse to the
InputSimulator DLL file
WindowsInput;"
虽然我无法告诉您可能需要什么 using 指令,但我不确定该工具是否允许您将输入发送到特定窗口。
您链接的页面的“历史记录”部分指出:
我知道这个问题的唯一解决方案涉及 SendMessage,也许您可以进一步解释问题出在哪里?
While I can't tell you what using directives you might need, I'm not sure this tool is going to allow you to send input to a specific window.
The "History" section of the page you linked states:
The only solution to this problem I am aware of involves SendMessage, maybe you could further explain where the problem was with that?