Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
1.96/5 (4 votes)
See more:
I want to handle two mices' click events in C#.
Posted
Updated 26-Aug-16 11:46am
v2
Comments
[no name] 14-Mar-12 14:50pm    
Why on earth would you want to do this at all?
ZurdoDev 14-Mar-12 14:55pm    
Do you need to do something depending on which mouse it is? You do not have to code for this. Mouse clicks and moves will be registered as normal.
Ed Nutting 14-Mar-12 15:03pm    
Edit: Don't SHOUT - it's annoying and rude.

Furthermore, this is a demand for code/answer not a question. A question explains the problem, says what you have tried already, shows some effort has gone into solving it and then asks a specific and clear question and lastly, has a question mark. Your post fails all of this hence it is a demand. Please update your question to fix this issue, then someone might be able to help.

Ed
Philippe Mori 14-Sep-15 13:05pm    
Even though, it usually does not make much sense, it is somewhat an interesting question...

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[^].
 
Share this answer
 
v2
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.
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900