What I'm trying to do: receive messages of other process window (Spy++).
For example: I opened new notepad window: https://i.stack.imgur.com/vNg6h.png
And then I moved the mouse over the notepad window, the windows will send this message to the notepad window (or to the main window child window/s):
WM_MOUSEMOVE xPos=100,yPos=200
I want to receive this message exactly when then mouse event is happening (by event or while loop) (probably while loop with Application.doEvents()
and Threading.Thread.Sleep(1)
).
What I have tried:
- create messages listener by the
ManagedSpyLib
(if you will import this library you can't compile your project... and if you will succeed to import this library it's not built for this mission) - I also searched about it and this is the most relevant result: http://www.codeproject.com/Articles/3923/InterSpy-An-integrated-Windows-message-trace-and-f but this is a c++ project and I'm trying to do it in C# or VB.NET.
Good example is better than explanation for me. :)
The hooks that you need for this are
WH_CALLWNDPROC
andWH_GETMESSAGE
. And these require DLL injection. You cannot inject managed code and so you will need to use unmanaged code for the hooking. You can then get your unmanaged injected DLL to communicate back to your C# application, but you will have to concede defeat on your attempts to write the hooking code in C#.