How to activate a new window in Python

Milon milon513 at
Mon Jul 19 19:28:20 CEST 2004

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,


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