How to disable selective keys on the keyboard?

Posted by Vilx- on Stack Overflow See other posts from Stack Overflow or by Vilx-
Published on 2010-04-21T14:32:03Z Indexed on 2010/04/21 14:33 UTC
Read the original article Hit count: 310

Filed under:
|
|

I'd like to write an application which disables certain keys on the keyboard while it's working. More specifically I'm interested in keys that might make the application loose focus (like ALT+TAB, WinKey, Ctrl+Shift+Esc, etc.) The need for this is has to do with babies/animals bashing wildly at the keyboard. :)

My first idea was to use SetWindowsHookEx, however I ran into a problem. Since I need a global hook, the procedure would have to reside in a .DLL which would get injected in all active applications. But a .DLL can be either 64-bit or 32-bit, not both. And on a 64-bit system there are both types of applications. I guess then that I must write two copies of the hook .DLL - one for 32-bit and the other for 64-bit. And then I'd also have to launch two copies of the application as well, because the application first has to load the DLL itself before it can pass it on to SetWindowsHookEx().

Sounds pretty clumsy and awkward. Is there perhaps a better way? Or maybe I've misunderstood something?

© Stack Overflow or respective owner

Related posts about Windows

Related posts about keyboard