1

What I'm trying to do: receive messages of other process window (Spy++).

For example: I opened new notepad window: http://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:

Good example is better than explanation for me. :)

4

2 回答 2

1

您需要查看HOOK。这就是 SPY++ 的工作原理。但是,.Net 不太适合这个,因为你必须使用很多 WIN32 API 函数。

于 2013-12-08T11:53:12.377 回答
1

您需要的钩子是WH_CALLWNDPROCWH_GETMESSAGE。而这些需要 DLL 注入。您不能注入托管代码,因此您需要使用非托管代码进行挂钩。然后,您可以让您的非托管注入 DLL 与您的 C# 应用程序进行通信,但您将不得不承认尝试用 C# 编写挂钩代码的失败。

于 2013-12-09T09:53:09.163 回答