Detecting a Key Press Squashed by Another Application

Posted by Eric Smith on Stack Overflow See other posts from Stack Overflow or by Eric Smith
Published on 2010-03-29T22:16:10Z Indexed on 2010/03/29 22:23 UTC
Read the original article Hit count: 379

Filed under:
|
|
|
|

I have a WPF application I'm planning to use as an overlay for a DirectX game (specifically Bad Company 2). I'm using WM_KEYBOARD_LL hook to detect KeyDown events so I can bring my app to the foreground when a specific button is pressed. This works perfectly except for when the game is running (I've also noticed this problem with Window's "Chess Titans" so it may be a DirectX thing).

As far as I can work out, when the game detects a keyboard press, it "eats" the event and doesn't pass the CallNextHookEx() method like it should, which would allow the key press message to be moved along to the next application in the queue.

I'm wondering if there's any sort of work-around to this? It seems kind of unfair that a single application can just willy-nilly eat up messages like that.

Thanks! :)

Relevant MSDN documentation: http://msdn.microsoft.com/en-us/library/ms644985%28VS.85%29.aspx

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf