Tracking mouse activity in C#

Posted on 2004-11-23
Last Modified: 2006-11-17

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:

Question by:dosdemon
    LVL 48

    Expert Comment

    LVL 48

    Accepted Solution


    Author Comment

    Sorry I checked back late.

    Let me go through these, will let you know about the result.

    Author Comment

    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

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now