| | |
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: 947 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for input, itunes, keyboard, mouse, python
address advice ajax amazon apple apps array beatles beginner box c++ code console corners curves data development downloads drm event examples excel facebook file fmradio ftp function google gui hack homework images input iphone ipod itunes java kazaa keyboard lala line linked linux list lists logitech loop malware mediaevent microsoft module mouse movingimageswithpygame mp3 music myspace nano napster news numeric output path peertopeer program programming projects py2exe pygame python random raw_input recursive ruby search security software string strings table text textbox threading time tkinter touchscreen tutorial ubuntu urllib urllib2 user variable vista voip windows windows7 write wxpython xlib xlwt youtube






