简体   繁体   English

如何在C#中接收非托管Win32和Win64应用程序的Windows消息?

[英]How to receive the windows messages of an unmanaged Win32 and Win64 app in C#?

I have an unmanaged app both in 32 bit and 64 bit on Windows 7 64. 我在Windows 7 64上有32位和64位非托管应用程序。

I want to write a C# application to receive the keyboard messages it's receiving, so I could do certain things on certain key presses, and for others, simply send it back to the app, so as not to interfere with them. 我想编写一个C#应用程序来接收它接收到的键盘消息,因此我可以在某些按键上执行某些操作,对于其他按键,只需将其发送回应用程序即可,以免干扰它们。

I don't know the right way to search for this so not sure how this would be done. 我不知道搜索此方法的正确方法,因此不确定如何执行此操作。

Also I want to avoid using keyboard hooks if possible. 另外,如果可能的话,我也想避免使用键盘挂钩。 Just want to receive the app's keyboard messages is what I am trying to do. 我只是想接收应用程序的键盘消息。

That's what keyboard hooks are designed for. 这就是键盘挂钩的用途。 There aren't any alternatives that don't have all the problems of keyboard hooks (and probably some additional ones). 没有任何替代方案不会解决键盘钩的所有问题(可能还有一些其他问题)。

See here about adding hooks to specific windows. 有关特定窗口中添加挂钩的信息,请参见此处 I've no idea how to read the message pump of other apps. 我不知道如何阅读其他应用程序的消息泵。 You can do it with a IMessageFilter but it only will work in the current app... 您可以使用IMessageFilter来完成此操作,但它仅在当前应用中有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM