views:

120

answers:

1

Hi all,

My hardware has a problem, from time to time it's sending a "keydown" followed by a "keyup" event:

keydown: None LButton, OemClear 255

keyup: None LButton, OemClear 255

keydown: None LButton, OemClear 255

keyup: None LButton, OemClear 255

It goes like this, every 1 or 2 seconds, forever, in Windows.

In general it doesn't affect most of the applications, because this key is not printable. I think it's a special function key, like a media key or something. It doesn't do anything.

But, in some applications that LISTEN to keydown and keyup, I get unexpected behaviour.

Question: is there a way to intercept these 2 keyboard events in Windows (for all applications & for Windows itself) and make the OS ignore them?

This is really important to me, if you can think of any solution, I'd be forever thankful.

A: 

You can write a small application that uses RegisterHotKey to register that keystroke as a System wide hotkey. Then Windows will turn that keystroke into a WM_HOTKEY message to your application window.

This will cause your app to run a bit of code once a second or so, which is not really ideal, but it's perhaps better than the alternative.

The window handle needs to belong to your application, but it doesn't have to be visible or very large. The hotkey is global, so it's a bit like installing a hook between the keyboard and other applications.

John Knoeller
Thanks that sounds good. Does it work for all threads and applications? I understand I need to pass an HWND parameter. What Window handle would that be?
Sg2010
Your comment made me found a solution. I used this article: http://www.codeproject.com/KB/cs/globalhook.aspx It hooks to global KeyDown and KeyUp events, and in the event handler I'm ignoring the unwanted events.
Sg2010