Link to home
Start Free TrialLog in
Avatar of dosdemon
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_MouseDown);
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs 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
Avatar of AlexFM
AlexFM

ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dosdemon

ASKER

Sorry I checked back late.

Let me go through these, will let you know about the result.
Thanks.
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.