如何在C#中分别处理两只老鼠 [英] How To Handle two mice separately in C#

查看:91
本文介绍了如何在C#中分别处理两只老鼠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在C#中处理两个小鼠的点击事件。

I want to handle two mices' click events in C#.

推荐答案

你没有。至少使用标准鼠标驱动程序,Windows无法处理多个鼠标,因此您的应用程序也无法执行此操作。



您可以将多个鼠标插入机器,但你只有一个鼠标指针。如果移动两个鼠标,它们将争夺鼠标指针的控制权。



获取多个鼠标指针的唯一方法是使用专门编写的鼠标驱动程序处理这个。例如, CPNMouse [ ^ ]。
You don't. At least with the standard mouse drivers, Windows doesn't handle multiple mice, so your app can't do it either.

You can plug multiple mice into the machine, but you only have the one mouse pointer. If you move both mice, they will "fight" for control of the mouse pointer.

The only way to get multiple mouse pointers is if you use mouse drivers specifically written to handle this. For example, CPNMouse[^].


Microsoft Mouse Mischief SDK是一个免费的多鼠标驱动程序,作为PowerPoint的插件实现,可能会对这一主题有所了解。似乎MS已经找到了如何提取每个鼠标的硬件设备ID并单独跟踪它们。我知道其他几个团体(公司)也已经想出如何为他们的软件应用程序做这件事。但我还没有自己开发代码。快速浏览一下MS SDK,看来他们正在使用USB端口相关的硬件信息,而不是设备携带的信息,无论如何都可能无法使用。
Microsoft Mouse Mischief SDK, a free multi-mouse driver implemented as an add-in for PowerPoint, may shed some light on this topic. It appears that MS has figured out how to extract the HW device ID for each mouse and track them separately. I know several other groups (companies) have also figured out how to do this for their software apps. But I haven't developed the code myself yet. A quick glance over the MS SDK it appears that they are using the USB port related HW info, instead of the device-carried info, which may not be available anyway.


从Windows Vista开始:



C ++&RawInput!



Unity插件示例:



C ++ DLL:http://pastebin.com/0Szi8ga6

Unity的C#脚本:http://pastebin.com/4h3CqpYy



检查这些。您至少应该能够理解C ++部分正在做什么以及它如何通过P / Invoke与C#脚本进行交互。
Since Windows Vista:

C++ & RawInput!

Example of Unity plugin:

C++ DLL: http://pastebin.com/0Szi8ga6
C# script for Unity: http://pastebin.com/4h3CqpYy

Check these. You should be able to at least understand what the C++ part is doing and how it interops with the C# script via P/Invoke.


这篇关于如何在C#中分别处理两只老鼠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆