views:

150

answers:

3

Hi there, I'm writing and app in Python that must be able to send keys or text to other app. For example, If I have Firefox open, I should be able to send it an URL to open it. I've already have the SendKeys module, and I read about the win32 module too, but I don't know if there's a way to filter out process without open windows.

Any help would be appreciated.

Thanks in advance.

+1  A: 

Usually, for this sort of "GUI automation" pyWinAuto is a good way to go. We use it to allow automated testing of GUI applications, and it ought to let you "type" URLs into Firefox (not to mention finding its window) as well.

Peter Hansen
Thanks for pointing to this module. It seems to be what I needed. ;) Going testing.
masterLoki
+1  A: 

Even if you need to use automation for everything else your app is going to do, it would probably be a lot easier to use the webbrowser module for opening urls in the user's browser.

DoR
Didn't know about this module, but I can grant this is a big headache saver since this is a rewrite from a C# app. And sending command to browser was hell on earth.
masterLoki
+1  A: 

try using dragonfly. It has a whole lot of automation stuff built into it. You don't need the speech recognition part in order to use the automation stuff. For example:

from dragonfly import Window
Window.get_all_windows()

will return a list of all the windows.

you also want to look at the FocusWindow() and Keys() objects in dragonfly.

reckoner
Woot, this worked perfectly!