Closed akzeitlos closed 3 years ago
Thank you for the report, and I apologise for this late reply.
I had to modify your script slightly to be able to run it:
from pynput.keyboard import HotKey, Key, KeyCode, Listener
def m(name):
def inner():
print(name)
return inner
executeAbro = m('executeAbro')
executeCopd = m('executeCopd')
executeDmd = m('executeDmd')
executeDms = m('executeDms')
executeKhk = m('executeKhk')
abro = HotKey(
[Key.ctrl, Key.shift, KeyCode(char='7')],
executeAbro
)
copd = HotKey(
[Key.ctrl, Key.shift, KeyCode(char='6')],
executeCopd
)
dmd = HotKey(
[Key.ctrl, Key.shift, KeyCode(char='5')],
executeDmd
)
dms = HotKey(
[Key.ctrl, Key.shift, KeyCode(char='0')],
executeDms
)
khk = HotKey(
[Key.ctrl, Key.shift, KeyCode(char='8')],
executeKhk
)
hotkeys = [abro, copd, dmd, dms, khk]
def signal_press_to_hotkeys(key):
for hotkey in hotkeys:
hotkey.press(l.canonical(key))
def signal_release_to_hotkeys(key):
for hotkey in hotkeys:
hotkey.release(l.canonical(key))
with Listener(on_press=signal_press_to_hotkeys, on_release=signal_release_to_hotkeys) as l:
l.join()
When running this, I only get one print of the formula name for each hotkey invocation. Does your system react differently?
I will close this due to lack of feedback. Please reopen if you have more information.
Hello, I have used Hotkey from pynput and everything works fine but the execute functions are activated twice, can anybody tell me why.
CODE