Detecting a Key Press Squashed by Another Application
- by Eric Smith
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