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 :D). 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

from msvcrt import getch

Anyone have any suggestions?

For the keyboard I use pyHook and pythoncom.
Try something like this.

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
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

really cool, thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.