from ctypes import * import pythoncom import pyHook def KeyStroke(event) print "[%s]" % event.Key, #输出键盘按下的键 return True k1 = pyHook.HookManager() k1.KeyDown = KeyStroke k1.HookKeyboard() pythoncom.PumpMessages()
时间: 2024-11-19 04:00:16
from ctypes import * import pythoncom import pyHook def KeyStroke(event) print "[%s]" % event.Key, #输出键盘按下的键 return True k1 = pyHook.HookManager() k1.KeyDown = KeyStroke k1.HookKeyboard() pythoncom.PumpMessages()