-1

I want to retrieve mouse information to my C# application, the information includes:

  • when Mouse position changes
  • When Mouse Clicks
  • When scroll wheel used or clicked

I have been able to find out how to get the mouse position from this question , but for other mouse information, I don't know yet. but I do know that I must use win api for that.

UPDATE: I need the information globally, not over my form or my controls, in fact my form is hidden , I just need to store mouse information during my application running.

Community
  • 1
  • 1
smohamed
  • 3,234
  • 4
  • 32
  • 57
  • All this information is available from events in windows forms and controls. Are you saying that you'd like to have this information on a global level? – Brandon Moore Nov 15 '11 at 08:32
  • 2
    look at the control/form events and you'll want to specify WPF or WinForms – kenny Nov 15 '11 at 08:32
  • 1
    Do you only need this information when the mouse is over your own window, or do you need it regardless of where the mouse is on the screen? (For the former, can override the Control.OnMouseMove/Click/Wheel methods in winforms; if you want this globally, you'll likely need to P/Invoke to SetWindowsHookEx to install a low-level mouse hook.) – BrendanMcK Nov 15 '11 at 08:34

1 Answers1

1

Generally individual controls want to know about mouse actions as it relates to them, which is why they have events that capture this information and you should use them accordingly.

However, if you have a need to see this information outside of your Forms then you'll need a global mouse hook. There is an article about that here: http://www.codeproject.com/KB/cs/globalhook.aspx

Brandon Moore
  • 8,590
  • 15
  • 65
  • 120