title: Runtime error in Python
body: <p>I was playing around with info I can get from key presses and mouse events in python and everything seems to work except when I quit the program I get this error.</p>
  
  <p>runtime error R6031 - Attempt to initialize the CRT more than once. This indicates a bug in your application.</p>
  
  <p>Here is my code not that it only happens when I press 'q' and the program quits.</p>
  
  <pre><code>import pythoncom, pyHook, sys
  def OnMouseEvent(event):
      # called when mouse events are received
      print 'MessageName:',event.MessageName
      print 'Message:',event.Message
      print 'Time:',event.Time
      print 'Window:',event.Window
      print 'WindowName:',event.WindowName
      print 'Position:',event.Position
      print 'Wheel:',event.Wheel
      print 'Injected:',event.Injected
      print '---'
      return True
  
  def OnKeyboardEvent(event):
      print "Message Name: ", event.MessageName
      print 'Message:',event.Message
      print 'Time:',event.Time
      print 'Window:',event.Window
      print 'WindowName:',event.WindowName
      print 'Ascii:', event.Ascii, chr(event.Ascii)
      print 'Key:', event.Key
      print 'KeyID:', event.KeyID
      print 'ScanCode:', event.ScanCode
      print 'Extended:', event.Extended
      print 'Injected:', event.Injected
      print 'Alt', event.Alt
      print 'Transition', event.Transition
      print '---'
      if chr(event.Ascii) == 'q':
          sys.exit()
      return True
  
  hm = pyHook.HookManager()
  hm.KeyDown = OnKeyboardEvent
  hm.MouseDown = OnMouseEvent
  hm.HookKeyboard()
  hm.HookMouse()
  pythoncom.PumpMessages()
  </code></pre>
  
  <p>Thanks in advance for the help!</p>