How to activate a new window in Python

M

Milon

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}")
 
L

Larry Bates

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.

HTH,
Larry Bates
Syscon, Inc.
 
T

Tim Golden

Milon said:
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?

[... snip example code ...]

Have a look at:

http://www.brunningonline.net/simon/blog/archives/000652.html

TJG
 
M

Miki Tebeka

Hello Milon,
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?
I don't know where "SendKeys" is coming from but you can use AutoIt through
the COM interface or using ctypes.

Bye.
 
T

Tony C

What/where is SendKeys ?????????????????

(e-mail address removed) (Milon) wrote in message >
import SendKeys
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,042
Latest member
icassiem

Latest Threads

Top