Joan Venge
Joan Venge

Reputation: 330862

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.

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.

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.

Upvotes: 1

Views: 564

Answers (2)

Sebastian Piu
Sebastian Piu

Reputation: 8008

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...

Upvotes: 1

Ben Voigt
Ben Voigt

Reputation: 283624

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).

Upvotes: 2

Related Questions