Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotkey combinations with the windows key disable system hotkeys #147

Open
sharat87 opened this issue Mar 30, 2018 · 5 comments
Open

Hotkey combinations with the windows key disable system hotkeys #147

sharat87 opened this issue Mar 30, 2018 · 5 comments

Comments

@sharat87
Copy link

If a hotkey like windows+c is defined with this module, all the other system hotkeys that use the windows key (like windows+e, windows+d, windows+1 etc.) stop working.

Sample code:

import keyboard
keyboard.add_hotkey('windows+c', lambda: print('windows+c'), suppress=True)
keyboard.wait()

While this program is running, hitting windows+c prints windows+c as expected, but all the other windows+ hotkeys don't work anymore.

@boppreh
Copy link
Owner

boppreh commented Mar 30, 2018

Thank you for the bug report.

Debugging notes:

Key suppression is tricky. For example, the initial "windows key press" event has to be suppressed, and if the next event is something like "d key press" then we have to simulate a "windows key press" to make up for the one we suppressed. But it should work in this case.

The fake "windows key press" event is being sent, but something about it is not quite right, and it appears to other hooks as nameless:

{"event_type": "down", "scan_code": 91, "time": 1522401926.756328, "is_keypad": false}
{"event_type": "up", "scan_code": 91, "name": "left windows", "time": 1522401926.7572875, "is_keypad": false}

It might be being sent with an incorrect virtual key code, or the fact that it's a special system key may be blocking the fake event.

Note that repeated key press events are not suppressed in this case, so you can press "windows+e" by holding down the windows key for a moment before pressing "e".

Edit: potentially related:

keyboard.send('windows') # works, and sends an event interpreted as "left windows" to other hooks
keyboard.send('left windows') # sends the exact same scan code, but nameless and doesn't work

@boppreh
Copy link
Owner

boppreh commented Mar 30, 2018

This one was very tricky, but I think it's fixed without breaking anything else. If you still experience problems, please leave a comment and I'll reopen the issue.

@sharat87
Copy link
Author

sharat87 commented Apr 1, 2018

Thanks for the quick turnaround @boppreh, but I still see the problem. Not sure if I'm doing something wrong. I installed the latest a few mins ago with the following command:

pip install --upgrade git+https://github.com/boppreh/keyboard.git#egg=keyboard

I also verified the changes in _winkeyboard.py from the commit 2544c0f, but the example script in my original post still blocks default windows+ hotkeys.

@boppreh
Copy link
Owner

boppreh commented Apr 1, 2018

Thank you for the reply, looking into it.

@sharat87
Copy link
Author

Hey @boppreh, don't mean to pester but I'm still interested in this one. Let me know if I can help some way. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants