How to activate a new window in Python

Larry Bates lbates at
Mon Jul 19 20:59:05 CEST 2004

Just run the application with os.system or use
win32process.CreateProcess to execute the
application (which gives you more control
over the window size, environment, etc.).
win32process is part of win32all extensions.

Larry Bates
Syscon, Inc.

"Milon" <milon513 at> wrote in message
news:3c9e9b1b.0407190928.61b1b292 at
> Hi all,
> I am new to Python, and I just wrote a simple script to launch an
> application from the windows's start menu's run command.  (see code as
> follow)  There is an "OK" button on the new application I launched,
> but I can't get Python to click on it because the new window is not in
> focus and I read somewhere off the web that I need to activate the new
> window first before I can do anything on the new window.  I couldn't
> find any useful information off the web, so, can someone please show
> me how to do it?
> Really appreciate it,
> Milon
> __________________________________________________________________
> import SendKeys
> # starts the TempApp using the windows start menu
> # run option
> def StartTempApp():
>     SendKeys.SendKeys( "{LWIN}{SLEEP .25}r")
>     SendKeys.SendKeys( "C:\\TempApp\\bin\\main")
>     SendKeys.SendKeys( "{ENTER}")
> # tab to OK button on the application and hit enter
> def StartTempApp():
>     SendKeys.SendKeys( "{TAB}{TAB}{ENTER}")

More information about the Python-list mailing list