78783

I want to stop pythoncom working

Question:

I was writing a code about keylogging by pyHook. The following codes are example:

import pythoncom as pc, pyHook as ph def KeyboardHook(event): print chr(event.Ascii) return True hm = ph.HookManager() hm.KeyDown = KeyboardHook hm.HookKeyboard() pc.PumpMessages()

I want to stop pythoncom's PumpMessages method for a while later (for example five seconds). But I couldn't find any answer to it.

I use: Windows 7, Python2.7

Thanks for answer.

Answer1:

You will have to use pythoncom.PumpWaitingMessages which is <strong>not</strong> blocking.

import pythoncom as pc, pyHook as ph import time def KeyboardHook(event): print chr(event.Ascii) return True hm = ph.HookManager() hm.KeyDown = KeyboardHook hm.HookKeyboard() while time.clock() < 5: pc.PumpWaitingMessages()

Recommend

  • Using jna to consume key events
  • Combining Tkinter mainloop with another event listener
  • change a keystroke passing a hook(c/c++)
  • Make fields editable when a button is clicked
  • Getting access to a binary response byte-by-byte in classic asp/JScript
  • PHP Script in my Wordpress Files. Please Decode or Help Me Remove it [closed]
  • Towers of Hanoi with “counter” in python
  • How do I make openssl_encrypt pad the input to the required block size?
  • Serverless Framework Dynamo DB Table Resource Definition with Sort Key
  • PHP in userdir not working
  • Send the string to its hex equivalent
  • remove unicode characters but keep all special and English characters with preg_replace
  • Why Encoding.ASCII != ASCIIEncoding.Default in C#?
  • JQuery Internet Explorer and ajaxstop
  • How to use an array of arrays with array_map(…) in PHP?
  • Different response to non-authenticated users and AJAX calls
  • jQuery show() function is not executed in Safari if submit handler returns true
  • Opengl-es onTouchEvents problem or a draw problem? [closed]
  • How to draw moving and Running sine wave chart using JFree chart in java?
  • output of program is not same as passed argument
  • Incrementing object id automatically JS constructor (static method and variable)
  • Eraser for UIBezierPath
  • How to limit post in wp_query
  • Upload files with Ajax and Jquery
  • Build own AppleScript numerical error handling
  • align graphs with different xlab
  • Return words with double consecutive letters
  • AngularJs get employee from factory
  • Java static initializers and reflection
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • Change div Background jquery
  • Linking SubReports Without LinkChild/LinkMaster
  • Bitwise OR returns boolean when one of operands is nil
  • Is there any way to bind data to data.frame by some index?
  • Django query for large number of relationships
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Reading document lines to the user (python)
  • How can I use `wmic` in a Windows PE script?
  • Python/Django TangoWithDjango Models and Databases
  • How to push additional view controllers onto NavigationController but keep the TabBar?