在 WPF 中模拟鼠标/键盘输入

发布于 2024-10-22 06:19:59 字数 382 浏览 1 评论 0原文

有许多与在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

儭儭莪哋寶赑 2024-10-29 06:19:59

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"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文