boppreh / keyboard

Hook and simulate global keyboard events on Windows and Linux.
MIT License
3.74k stars 432 forks source link

change suppress in run-time #623

Open nixON232 opened 6 months ago

nixON232 commented 6 months ago
 def parse_hotkey_manager(hotkey_manager):
...
    for key in hotkey_manager:
#hotkey_manager[key] is some_func
        keyboard.add_hotkey(key, hotkey_manager[key], suppress=True)
...
 def some_func():
if not self.myWindow:
  keyboard.suppress=False

I want to create global hotkeys which work for specific windows (suppress=true) and don't work for others (suppress=false). Any solutions?

mriot commented 6 months ago

You could try to get the currently active window and set/remove the hotkeys accordingly.