Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. from pyHook import HookManager
  2. from win32gui import PumpMessages, PostQuitMessage
  3.  
  4. class Keystroke_Watcher(object):
  5.     def __init__(self):
  6.         self.hm = HookManager()
  7.         self.hm.KeyDown = self.on_keyboard_event
  8.         self.hm.HookKeyboard()
  9.  
  10.  
  11.     def on_keyboard_event(self, event):
  12.         try:
  13.             if event.KeyID  == 67:
  14.                 self.your_method()
  15.         finally:
  16.             return True
  17.  
  18.     def your_method(self):
  19.         print("kek")
  20.  
  21.     def shutdown(self):
  22.         PostQuitMessage(0)
  23.         self.hm.UnhookKeyboard()
  24.  
  25.  
  26. watcher = Keystroke_Watcher()
  27. PumpMessages()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement