在 WPF 中模拟鼠标/键盘输入
有许多与在 WPF(以及 Windows)中模拟鼠标/键盘输入相关的问题。我想我的问题与通常的问题有些不同,我想听听您的意见。我见过的大多数帖子都有一个特定的更高级别的操作:我想单击它,我想将鼠标移动到这里,等等。要模拟这些,可以简单地使用路由事件。但是,我希望从远程应用程序操作鼠标,并希望在低级别输入鼠标事件:当前鼠标位置是 x,y,按钮状态是这样那样。我的目标框架是 WPF,但如果像通用虚拟鼠标驱动程序这样的东西是可行的,我也对此很满意。我没有安全问题:接收消息的应用程序将由我在更高级别进行编码,因此我不需要疯狂的黑客攻击。我愿意使用托管或非托管代码,并尽可能深入地研究兔子洞以完成这项工作,但我不想重新发明轮子。我也可以将我的应用程序托管在 HwndHost 或类似的主机中,以防我需要访问 Windows 消息。
想法?
There are many questions relating to simulating mouse/keyboard input in WPF (and Windows, for that matter). I have something a little different than the usual question, I think, and I'd like your input. Most posts I've seen have a specific higher level action in mind: I want to click this, I want to move the mouse here, etc. To emulate these, one can simply use routed events. However, I'm hoping to operate a mouse from a remote app and would like to input mouse events at a low-level: current mouse position is x,y and button state is such and such. My target framework is WPF, but if something like a generic virtual mouse driver is the way to go, I'm cool with that too. I do not have security concerns: the apps receiving the messages will be coded by me at a higher level, so I don't need crazy hacks. I'm willing to use managed or unmanaged code and take the rabbit hole as deep as it needs to go to make this work, but I don't want to reinvent the wheel. I can host my apps in an HwndHost or some such too, in case I need access to windows messages.
Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WPF 具有一些内置的自动化功能。这有点复杂,我自己从未真正尝试过,但我最近一直在阅读有关它的内容 - 可能值得一看:
http://msdn.microsoft.com/en-us/library/ms747327.aspx
或在 google 中搜索“WPF 自动化”
WPF has some built-in automation capabilities. It's a bit complicated, and I've never actually tried it myself, but I've been reading about it recently - it might be worth checking out:
http://msdn.microsoft.com/en-us/library/ms747327.aspx
Or search google for "WPF automation"