How do I intercept messages being sent to a window?

后端 未结 2 389
失恋的感觉
失恋的感觉 2020-12-14 22:54

I want to intercept messages that are being sent to a window in a different process. What is the best way to do this? I can\'t see the messages when I use the WH_GETMESSAGE

2条回答
  •  自闭症患者
    2020-12-14 23:11

    If the message is sent rather than posted WH_GETMESSAGE won't see it. You need WH_CALLWNDPROC. If you're working across processes you'll need a system-wide hook in a DLL. You don't mention how you invoked SetWindowsHookEx, so I don't know if your hooking failed because it wasn't global, or because the message you were looking for was sent.

    If you haven't worked with system-wide hooks before, I have an example of a system-wide hook on my website here. That's a keyboard hook, but the principle is the same.

    Stop me if I'm unintentionally talking down here - your question was so short I can't infer your expertise level. But messing around with hooks does imply some experience...

提交回复
热议问题