Search code examples
windowshotkeysregisterhotkey

How to register F12 as a hotkey


Per this article:

The F12 key is reserved for use by the debugger at all times, so it should not be registered as a hot key. Even when you are not debugging an application, F12 is reserved in case a kernel-mode debugger or a just-in-time debugger is resident.

However, somehow there is a workaround as AutoHotkey works with F12. Does anybody have any idea how?


Solution

  • I'm still not sure how AutoHotkey does it after looking at the source for a short bit. However, I began to think about things differently. Instead of trying to use RegisterHotKey as I have done for all other keys, I decided to try listening to ALL keys. And, VOILA, using a low level keyboard hook from Stephen Toub, I am now able to at least see the F12. I'll use RegisterHotKey for everything else, but will listen for F12 separately via this hook.