如何在 C# 中创建多个单独工作的鼠标控件?

发布于 2024-12-11 01:33:59 字数 335 浏览 1 评论 0原文

我正在用 C# 实现一个程序,它可以同时“玩”游戏的多个实例。生成的实例的操作基于我的操作。例如,当我单击主实例的 X、Y 位置时,所有其他生成的实例中的同一位置都会出现鼠标单击。

我可以通过挂钩鼠标事件来执行鼠标单击、鼠标按下、鼠标向上操作,并根据每个游戏窗口的位置模拟相同的鼠标单击位置。然而,如果涉及到鼠标拖动,这种方法就没有帮助。当我必须循环所有游戏实例来进行虚拟鼠标单击时,它的性能会受到一些影响。

我发现可以使用 Microsoft 的 MultiPoint SDK 创建多个鼠标。但是,我找不到任何有关是否可以在 C# 中模拟多个鼠标单击事件(除了我的事件)的文档?如果是的话我该怎么办?

谢谢

I am implementing a program in C# which can "Play" multiple instance of a game at the same time. The actions of the spawned instance is based on my actions. For example, when i click at position X, Y of the main instance, there will be mouse click at the same position in all other spawned instance.

I can do the mouse click, mouse down, mouse up by hooking the mouse event, and simulate the same mouse click on position based on the position of the each game window. However, this approach does not help if it comes to mouse dragging. And it has some setback in performance when i have to loop all my game instances to do a virtual mouse click.

I have found out that it is possible to create multiple mouse using the MultiPoint SDK from Microsoft. However, I could not find any documentation about if it is possible to simulate the multiple mouse click events (other than mine) in C#? If it is then how can i do it?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

原谅过去的我 2024-12-18 01:33:59

除非您正在操作一个不是您编写的程序,否则我认为您可能使用了错误的 API 来完成这项工作。

如果您需要在多个窗口上编写多个操作的脚本,那么最好按顺序运行它们。编码和调试将变得更加容易,并且您无需执行任何特殊操作。只需按顺序编写每个操作的脚本,然后执行它们即可。

Unless you are manipulating a program you didn't write, I think you might be using the wrong API for the job.

If you need to script multiple actions on multiple windows, you are probably better off running them sequentially. It will be easier to code and debug and you won't have to do anything special. Just script each action sequentially and then execute them.

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