Closed dalyIsaac closed 3 years ago
Would anyone be interested either implementing or reviewing a pull request to move from RegisterHotKey to SetWindowsHookEx?
I'd be willing to guide someone to do this 👍. I tried to do this myself a few months back, but hit a problem which I couldn't solve, but I can't remember what the issue was.
I've been looking through the issues in the last day or two, looking for something I could potentially contribute to. I'm still poking around the code base, but if you're willing to give me a point to launch from @TimUntersberger I'd like to give it a go.
I'm still poking around the code base, but if you're willing to give me a point to launch from @TimUntersberger I'd like to give it a go.
IMO the first step would be to play with how using low level keyboard hooks could work in a simple prototype project. This would make it easier to test things.
The easiest way for us to do this would be to somehow emit an event about what happened in the hook into our application.
Almost all of the keybinding related stuff is in this file, but just try for yourself what feels like the right solution. If we have to completely rewrite our keybinding stuff to have a better solution then so be it.
Thank you for giving this a shot 👍
@alex-griffiths in the keyboardhook branch you can see a basic setup for the keyboardhook. One thing I am already noticing are performance problems.
Hopefully you can use this as a base.
Edit:
The source of the performance issue is that we have to wait for a response from the main loop before returning from the keyboard hook. Which is really bad for the performance. If we don't wait for a response we can't block the event from going through.
I think I fixed it myself.
Ha well I guess I'll just keep playing around with it a bit just to get more familiar with the code base.
In the
Keybindings
section of the documentation it states that:This is due to nog using the
RegisterHotKey
API. However, other applications have been able to allow users to use the Windows key in shortcuts. For example, both PowerToys and workspacer useSetWindowsHookEx
:https://github.com/microsoft/PowerToys/blob/70b9c0f879c217db05e42763a308450125fe1550/src/common/interop/KeyboardHook.cpp#L30-L54
https://github.com/rickbutton/workspacer/blob/32783981f22ed2bbf7a32565888b3a27dcf923e7/src/workspacer/Keybinds/KeybindManager.cs#L40-L58
Would anyone be interested either implementing or reviewing a pull request to move from
RegisterHotKey
toSetWindowsHookEx
?