Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1181
  • Last Modified:

Tracking mouse activity in C#


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:

  • 2
  • 2
1 Solution
dosdemonAuthor Commented:
Sorry I checked back late.

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now