Jump to content
Sign in to follow this  
RyanOlson

Winactive issue

Recommended Posts

RyanOlson

Ok I am trying to automatically install tune up utilities 2008 on a computer but for some reason autoit will not see the windows wether using winwaitactive i've tried process active and I have tried gettting the handle and using that with no luck the script just stops once it get's to an open tune up utilz window. here is the sample of the bigger code with the handle

if WinWaitActive("Open File - Security Warning") then

send("!r")

$handle = WinGetHandle("TuneUp Utilities 2008 Setup", "")

WinWaitActive($handle)

send("!n")

send("!a")

send("!n")

send("!n")

send("!n")

EndIf

Share this post


Link to post
Share on other sites
PsaltyDS

Ok I am trying to automatically install tune up utilities 2008 on a computer but for some reason autoit will not see the windows wether using winwaitactive i've tried process active and I have tried gettting the handle and using that with no luck the script just stops once it get's to an open tune up utilz window. here is the sample of the bigger code with the handle

if WinWaitActive("Open File - Security Warning") then

send("!r")

$handle = WinGetHandle("TuneUp Utilities 2008 Setup", "")

WinWaitActive($handle)

send("!n")

send("!a")

send("!n")

send("!n")

send("!n")

EndIf

You are looking for two windows there, which one is giving you trouble? If you are seeing the first, but not the second, then I think it's a timing issue. There is no "wait" before looking for the second window. I may not be there yet when you try to get the handle.

Also, you didn't ask but: To improve reliability, once you get the window handle use ControlSend() vice Send() wherever possible.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
k3v

Have you tried ControlSend instead of Send? (this should work whether the window is active or not)

Share this post


Link to post
Share on other sites
RyanOlson

IM looking for the second window the first window is a stupid windows security run window that opens then that get's closed the issue then is the next program window when it comes up.

Share this post


Link to post
Share on other sites
PsaltyDS

IM looking for the second window the first window is a stupid windows security run window that opens then that get's closed the issue then is the next program window when it comes up.

Like I said in post #2: You need to wait for the window before getting the handle:
WinWait("TuneUp Utilities 2008 Setup", "")
$handle = WinGetHandle("TuneUp Utilities 2008 Setup", "")
WinWaitActive($handle)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
RyanOlson

The problem is I don't think anything is working to find the window I first used plain old winwaitactive and it would not work .

Share this post


Link to post
Share on other sites
k3v

I've resorted to this before...

while 1
    if winexists($myhandle)
         do stuff
         exitloop
    endif
  ;(maybe time your loop out here in case the window is never recognized)
wend
Edited by k3v

Share this post


Link to post
Share on other sites
RyanOlson

Still no go it is like the window does not exist but does exist.

Share this post


Link to post
Share on other sites
k3v

Is there any useful information about the window you can find from using the AutoIT Window Info utility?

Share this post


Link to post
Share on other sites
RyanOlson

>>>> Window <<<<

Title: TuneUp Utilities 2008 Setup

Class: MsiDialogCloseClass

Position: 259, 220

Size: 506, 392

Style: 0x14CA0000

ExStyle: 0x00040100

Handle: 0x002C091C

>>>> Control <<<<

Class:

Instance:

ClassnameNN:

Advanced (Class):

ID:

Text:

Position:

Size:

ControlClick Coords:

Style:

ExStyle:

Handle: 0x00180754

>>>> Mouse <<<<

Position: 754, 226

Cursor ID: 2

Color: 0xFF6250

>>>> StatusBar <<<<

>>>> Visible Text <<<<

&Next >

< &Back

Cancel

Welcome to the

TuneUp Utilities 2008

Installation Wizard

side16

WARNING: This program is protected by copyright law and international treaties.

Click Cancel to quit the setup program, then close any programs you have running. Click Next to continue the installation.

It is strongly recommended that you exit all Windows programs before running this setup program.

Unauthorized reproduction or distribution of this program, or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under law.

>>>> Hidden Text <<<<

Share this post


Link to post
Share on other sites
k3v

I might try the things you've already tried, but using the window's title instead of it's handle... if that doesn't work, I'm afraid I'm fresh out of ideas.

Share this post


Link to post
Share on other sites
RyanOlson

Thanks k3v I did try that that's when i thought hey maybe the handle now I think i am just up a creek and those tricky developers must have somoe anti script thing working against me.

Share this post


Link to post
Share on other sites
k3v

one final note, I'm sure you already corrected this, but as PsaltyDS mentioned, you do need to wait for the window to be active before you can get its handle... so my earlier loop example would'nt work if you attampted to get the handle before the window was active... try the loop using the window's title.

Share this post


Link to post
Share on other sites
RyanOlson

yah tried a 30 second sleep. no bueno hahaha

Share this post


Link to post
Share on other sites
RyanOlson

Ok bringing this back up to see if this is a bug some how or I need something else. I was bored so I started looking at the issue again and found out what is happening. here is the code

Run ( "temp\tune.exe" , "" )
If WinExists("TuneUp Utilities 2008 Setup") Then
    Sleep(5000)
    Send ("!n")
    EndIf

IF I run it that way it does not work now if I add a long enough pause say like this

Run ( "temp\tune.exe" , "" )
sleep(10000)
If WinExists("TuneUp Utilities 2008 Setup") Then
    Sleep(5000)
    Send ("!n")
    EndIf

Then it will send the alt n to move to the next option. I am on winexitst right now because this is when I discovered the issue it works with winwaitactive and everything with the pause the issue is if I set it to win wait active shouldn't it wait till the window is up before killing the script.

What I mean is if it looks like this

Run ( "temp\tune.exe" , "" )
If WinWaitActive("TuneUp Utilities 2008 Setup") Then
    Sleep(5000)
    Send ("!n")
    EndIf

Shouldn't it wait till there is focus on the tune up window

Share this post


Link to post
Share on other sites
RyanOlson

Never mind you can close this I got it just had to use the time out function which I have never used before

Share this post


Link to post
Share on other sites
TerarinKerowyn

RunWait( "temp\tune.exe" , "" )
If WinExists("TuneUp Utilities 2008 Setup") Then
    Send ("!n")
EndIf

This should work regardless to if anything is working but I would get the handle of the Window before hand such as

Dim $handle

RunWait( "temp\tune.exe" , "" )

If WinExists( "TuneUp Utilities 2008 Setup") Then
    WinActivate( "TuneUp Utilities 2008 Setup")
    
    $handle = WinGetHandle( "TuneUp Utilities 2008 Setup")
    If @error Then
        MsgBox(4096, "Error", "Could not find the correct window")
    EndIf
EndIf

If $handle Then
;   ControlSend( $handle, , <ControlID>, "!n") or Send("!n)
EndIf

The ControlSend works without the window being active so choose what one you'd like to, I don't know the controlID so you have to know it by check on your windows thing


Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.