| | |
grab mouse and key input outside of python window
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
hi everyone. just recently I've been messing around with controlling itunes with python (you should check it out on google; some pretty fun stuff to mess with
). I've already got all of my functions down, but my questions is that how would I go about grabbing keyboard/mouse input (mouse buttons, not really mouse movement) outside of the python window? (or while a different window is the current active window). I know how to get keyboard input inside of the python window using
Anyone have any suggestions?
). I've already got all of my functions down, but my questions is that how would I go about grabbing keyboard/mouse input (mouse buttons, not really mouse movement) outside of the python window? (or while a different window is the current active window). I know how to get keyboard input inside of the python window using python Syntax (Toggle Plain Text)
from msvcrt import getch
Anyone have any suggestions?
0
#2 Oct 12th, 2009
For the keyboard I use pyHook and pythoncom.
Try something like this.
I haven't tested this actual code, but play around with it.
I have an example using this http://www.daniweb.com/forums/thread229564.html
Try something like this.
Python Syntax (Toggle Plain Text)
import pythoncom, pyHook, sys def OnKeyboardEvent(event): x = chr(event.Ascii) print "Key: ", chr(event.Ascii) #do something here #x can be a conditional for something return True #,return x hm = pyHook.HookManager() hm.KeyDown = OnKeyboardEvent hm.HookKeyboard() pythoncom.PumpMessages() #will wait forever
I haven't tested this actual code, but play around with it.
I have an example using this http://www.daniweb.com/forums/thread229564.html
Last edited by Tech B; Oct 12th, 2009 at 3:52 pm. Reason: code tag fix
"In worn down shoes i found redemption; judge me not for I've walked with sin...."
~K.B. Carte
~K.B. Carte
![]() |
Similar Threads
- Starting Python (Python)
- How to do Input in Python? (Python)
- Detect key input (Visual Basic 4 / 5 / 6)
- pygame window not werking (Python)
- special keys as inputs (Game Development)
Other Threads in the Python Forum
- Previous Thread: How to do Input in Python?
- Next Thread: call function from string (with arguements)
Views: 978 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for input, itunes, keyboard, mouse, python
ajax amazon apple arax array asp backend beatles beginner bestbuy bluetooth bobdylan c++ ces code coordinates copy copyright def downloads drm error examples excel facebook file function google gui hack input iphone ipod itunes itunesstore jaunty java keyboard launcher linux list lists loop malware microsoft mouse mp3 mp3player music mysql nano napster newb news numeric output parameters pointingdevice programming projects push py2exe pygame pyglet pyqt python random recursive redirect ruby security simple software source string strings strip syntax table terrorism text text-file textbox threading tkinter touchscreen trick tutorial ubuntu urllib urllib2 user variable vista warnerbrothers wikipedia windows windows7 wxpython youtube






