How can I track the click of the keyboard button if the Python script is launched in the background?
question@mail.ru
·
01.01.1970 03:00
Python 3 how to track the click on the buttons
answer@mail.ru
·
01.01.1970 03:00
You can track the buttons press through the keyboard :
Pip Install keyboard -
this is an example to track click on hot buttons:
Import keyboard def foo (): print ( 'World' ) keyboard.add_hotkey ( '' "ctrl + 1 ', lambda : print ( 'Hello' )) keyboard.add_hotkey ( '' ctrl + 2 ', foo) keyboard.wait (' '' Ctrl + Q ') -
tracking of all clicks on the buttons:
Import keyboard def print_pressed_keys ( e ): Print (E.Event_type, E.NAME) keyboard.Hook (print_pressed_keys) keyboard.wait ()