Question

Is it possible in C# to listen to mouse related windows messages sent to other windows in other processes?

Was it helpful?

Solution

There is a open source project in codeplex for that
Application and Global Mouse and Keyboard Hooks .Net Libary in C#
If you want to do this yourself do some extra search on Windows Hooks
This article shows how

OTHER TIPS

You can take a look at the Codeplex Application and Global Mouse and Keyboard Hooks library

This library attaches to windows global hooks, tracks keyboard and mouse clicks and movement and raises common .NET events with KeyEventArgs and MouseEventArgs, so you can easily retrieve any information you need:
Mouse coordinates
Mouse buttons clicked
Mouse wheel scrolls
Key presses and releases
Special key states

From above links Documentation:

Before beginning it is important to know that hooking terms can and will be used interchangeably. Global hooks are also known as System, or System-Wide hooks, and will encompass the entire operating system. Application hooks are often called Local, because as the name implies, will only correspond to the single application which placed the hook (or a specific thread).

There is no managed way to do this. However, with Windows Api this is possible:

This should help you.

C# - Capturing Windows Messages from a specific application

It would be a good start to capture WM_MOUSEMOVE http://msdn.microsoft.com/en-us/library/windows/desktop/ms645616(v=vs.85).aspx

But there are other mouse related window messages, too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top