views:

545

answers:

3

I'm automating some common GUI tasks I have to do in an application, and I'm using a Python program and SendKeys to do it. So far I've had to activate the application I'm sending keys to (since SendKeys just sends the keystrokes to the active window), but I'd like to be able to send keystrokes to an application in the background. Is there a way to do that, or am I dreaming an impossible dream?

Thanks for your help.

+1  A: 
SendKeys is a Python module for Windows that can send one or more keystrokes or keystroke combinations to the active window.

If you need to do some automated work in the background, make another user/session and do it in that.

However if you must do something of this like on windows, I always reach for autoit.

It's M$ only and perfectly suited to automating tasks on that OS.

Nazarius Kappertaal
A: 

This is a frequent question in the autohotkey.com forums. Search under "sending commands to controls". Basically, if you have the control ID, then it doesn't need to be visible in order to operate on it. There're more details on the forums.

good luck!

reckoner
A: 

pywinauto is another MS-only GUI automation tool, this one written in Python.

Ryan Ginstrom