0

I used to use the RegisterHotkey method but users have had issues based on their keyboard. For example, the hotkey does not work while a command prompt is focused. Or if the ctrl+alt+del dialog is focused. The LowLevelKeyboardHook worked uniformly across all users.

I had an issue though with modifiers. For instance if the hotkey is Win+F. If the user first:

  1. downs the Win, I allow it
  2. then downs the F key, I block it
  3. if user ups the F key then I block it too
  4. however, on up of the Win key, it comes through and the start menu opens

I tried blocking the Win key on step 4. However this causes it stays depressed in the keyboard buffer (pressing L for instance will lock the computer).
Is there a way to clear the keyboard buffer?
I was thinking of blocking the up, but after all keys are released, then clear the buffer.

I tried the method from this SO answer, but it didn't work:

#include <conio.h>
while (_kbhit()) {
    _getche();
}
Community
  • 1
  • 1
Noitidart
  • 35,443
  • 37
  • 154
  • 323
  • From the documentation for the `RegisterHotKey` function: *"Keyboard shortcuts that involve the WINDOWS key are reserved for use by the operating system."* Do you work for Microsoft? – Cody Gray - on strike Dec 21 '16 at 10:30
  • Oh I know that @CodyGray I was just using it as example as it demonstrates it very well. My actual use case is with Alt as a modifier as it opens various menus/toolbars. – Noitidart Dec 21 '16 at 11:04

0 Answers0