Possible Duplicate:
Getting mouse position in c#
Is it possible to mimic a peripheral , say , a mouse on one of the ports and write a program that could send a click to an (x,y) on the display ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes you can. I did a MouseController for NUnitForms years ago. Check out http://nunitforms.sourceforge.net/
The source code of the mouse controller is at http://nunitforms.svn.sourceforge.net/viewvc/nunitforms/trunk/nunitforms/source/NUnitForms/MouseController.cs?revision=32&view=markup
The key is using the Win32 function SendInput; http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx
The SendInput function takes a union as input, which is not easily supported by C#. What I have done is to define two functions SendMouseInput and SendKeyboardInput that specify different input structs but call the same function.