Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pyHook import HookManager
- from win32gui import PumpMessages, PostQuitMessage
- class Keystroke_Watcher(object):
- def __init__(self):
- self.hm = HookManager()
- self.hm.KeyDown = self.on_keyboard_event
- self.hm.HookKeyboard()
- def on_keyboard_event(self, event):
- try:
- if event.KeyID == 67:
- self.your_method()
- finally:
- return True
- def your_method(self):
- print("kek")
- def shutdown(self):
- PostQuitMessage(0)
- self.hm.UnhookKeyboard()
- watcher = Keystroke_Watcher()
- PumpMessages()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement