我正在通过 pyHook 编写有关键盘记录的代码。以下代码是示例:
import pythoncom as pc, pyHook as ph
def KeyboardHook(event):
print chr(event.Ascii)
return True
hm = ph.HookManager()
hm.KeyDown = KeyboardHook
hm.HookKeyboard()
pc.PumpMessages()
我想稍后(例如五秒钟)停止 pythoncom 的 PumpMessages 方法。但我找不到任何答案。
我使用:Windows 7,Python2.7
感谢您的回答。