dosdemon
asked on
Tracking mouse activity in C#
Hi,
I am making a windows form application in C#.
I want to be able to catch ALL the activitites/events that the mouse goes through i.e. move, left click in, left click out (=aka drag), right click in, right click out, mouse scroll etc.
Its very simple setting up event handlers in the app as:
// ---------- start of snippet --------------
this.MouseDown += new MouseEventHandler(Form1_Mo useDown);
private void Form1_MouseDown(object sender, System.Windows.Forms.Mouse EventArgs e)
{
//blah blah
}
// ---------- end of snippet --------------
BUT, the catch is that I dont only want to capture the mouse activities on my form, BUT INSTEAD I want it to monitor the mouse activities even if my form is not in focus, and even when the mouse is not over the form area.
Picture this application as something which is monitoring every signal recieved from the mouse.
Any help will be appreciated.
This is related to my question, but cant figure out much from it:
https://www.experts-exchange.com/questions/21215146/Simulate-Mouse-movement-in-C.html
Thanks
I am making a windows form application in C#.
I want to be able to catch ALL the activitites/events that the mouse goes through i.e. move, left click in, left click out (=aka drag), right click in, right click out, mouse scroll etc.
Its very simple setting up event handlers in the app as:
// ---------- start of snippet --------------
this.MouseDown += new MouseEventHandler(Form1_Mo
private void Form1_MouseDown(object sender, System.Windows.Forms.Mouse
{
//blah blah
}
// ---------- end of snippet --------------
BUT, the catch is that I dont only want to capture the mouse activities on my form, BUT INSTEAD I want it to monitor the mouse activities even if my form is not in focus, and even when the mouse is not over the form area.
Picture this application as something which is monitoring every signal recieved from the mouse.
Any help will be appreciated.
This is related to my question, but cant figure out much from it:
https://www.experts-exchange.com/questions/21215146/Simulate-Mouse-movement-in-C.html
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry I checked back late.
Let me go through these, will let you know about the result.
Thanks.
Let me go through these, will let you know about the result.
Thanks.
ASKER
AlexGM:
Thanks for the code, it worked well and the way I want it EXCEPT that it does not currently tracks mouse clicks and scrolls etc, I guess I will have to go thru the DLLs doc and structures to know how to capture that too.
Thanks for your help.
Thanks for the code, it worked well and the way I want it EXCEPT that it does not currently tracks mouse clicks and scrolls etc, I guess I will have to go thru the DLLs doc and structures to know how to capture that too.
Thanks for your help.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/setwindowshookex.asp