gmamaladze / globalmousekeyhook

This library allows you to tap keyboard and mouse, detect and record their activity even when an application is inactive and runs in background.
MIT License
1.05k stars 257 forks source link

Detecting Key Combinations vs. WM_HOTKEY #134

Open chrkon opened 3 years ago

chrkon commented 3 years ago

I have tested the 'Key Detecting' function on my system with the ConsoleHook example.

If I run the example without elevated rights, it can only catch keystrokes made by other 'non elevated' applications. Keystrokes made in an elevated console window can only be catched, if the example itself is run with elevated rights. I think this is a correct behaviour.

But I was wondering why other apps can handle even keystrokes from elevated Apps. Then I found the difference. The other apps don't catch all Keystrokes. They register global hot keys in the system. After this registration the system will send a WM_HOTKEY message which can be handled.

O course there is a little constraint. Windows Hotkeys can only handle combinations of "Alt, Control, Shift, Win" with one(!) other key. So Control+Shift could not be registered as Hotkey.

I think both issues ('catching Keystrokes from elevated Apps' and the 'difference between Windows Hotkey and Detecting Key Combinations') should be mentioned in the documentation.