Jump to content

WinExists fails where WinWait succeeds


Recommended Posts

Running 3.1.1.1 (had 3.1.1.16 beta installed but moved it out).

I'm scripting a install that uses the MSVB installer.

I'm finding that the following line using WinWait works:

WinWait("MSO Log Data v2.5.404 Setup","E&xit Setup")

Whereas the following line using WinExists fails:

WinExists("MSO Log Data v2.5.404 Setup","E&xit Setup")

Due to the structure of my auto(IT)mator script, I want to use WinExists.

Any ideas why WinWait and WinExists are acting so differently

TIA

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

Looking at your example script, I think you need to give the Case statements something to evaluate.

$done = 0
While Not $done
    Select
        case WinExists("Adobe Reader 7.0 - Setup","Setup has determined that you already have another app") = 1
            ControlClick("Adobe Reader 7.0 - Setup","Adobe Acrobat 7.0","Button4")
        case WinExists("Adobe Reader 7.0 - Setup","ReaderSpalsh") = 1
            ControlClick("Adobe Reader 7.0 - Setup","InstallShield","Button1")
        case WinExists("Adobe Reader 7.0 - Setup","Setup will install Adobe Reade") = 1
            ControlClick("Adobe Reader 7.0 - Setup","Setup will install Adobe Reade","Button1")
        case WinExists("Adobe Reader 7.0 - Setup","Change &Destination Folder...") = 1
            ControlClick("Adobe Reader 7.0 - Setup","Change &Destination Folder...","Button1")
        case WinExists("Adobe Reader 7.0 - Setup","Click Install to begin the ins") = 1
            ControlClick("Adobe Reader 7.0 - Setup","Click Install to begin the ins","Button1")
        case WinExists("Adobe Reader 7.0 - Setup","Setup has successfully install") = 1
            ControlClick("Adobe Reader 7.0 - Setup","Setup has successfully install","Button1")
            $done = 1    
    EndSelect
        
    TrayTip("Please wait - Installing", $appname & " (" & Round(TimerDiff($begin) / 1000, 0) & " secs)...", 30, 17)
    Sleep(1000)
WEnd

Case WinExists() = 1

;Do action

It needs something to evaluate, to recognize a condition as being true or false. In this case, 0 is false, 1 is true. As those are the returns of WinExists().

:(

Edit: Although, I do not know why WinExists() needs = 1 to work, when example below does not. Perhaps a au3 developer can explain why ?

Select
    Case 0
    MsgBox(0, 'Case', '0')
    Case 1
    MsgBox(0, 'Case', '1')
EndSelect

Does the same with beta, with True and False.

Maybe WinExists() requires the If keyword, to be workable ?

Does seem odd ? :(

Edited by MHz
Link to comment
Share on other sites

Is this beta or release?

Lar.

<{POST_SNAPBACK}>

Have tested on both.

True and False, only on beta though.

Edit: Although, I just tested on this on the release, it works. I do not understand why it works now. :">

Select
    Case WinExists('AutoIt Help')
    MsgBox(0, 'Case', '0')
    Case WinExists('AutoIt Forums')
    MsgBox(0, 'Case', '1')
EndSelect
Edited by MHz
Link to comment
Share on other sites

Sorry..my code was out of context. The WinExists() is in a Select.

However, WinExists() is returning 0 even thou the window does exist. If I do a WinWait() for the same window with the same params, WinWait returns 1.

Note of some import: I've noticed *funny* things with other VB constructed setups before like not seeing text on the window and such (even via AutoIT Window Info). Buttons, frames, and other elements are seen with names like 'ThunderRT6button4', 'ThunderRTcommandbutton1', 'ThunderRTframe1' and such.

This has required me to resort to Sleep()+Send() vs. WinExists()+ControlClick()

The latter being my prefered coding choice.

Really weird.

Any help getting WinExists to work again would be great.

TIA

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

Is everyone missing the obvious?

WinWait -- script is essentially paused until window with that title appears

WinExists -- just check if window exists and immediately continue with rest of script

Thus, the following is equivalent to WinWait:

Do
   sleep(250)
Until WinExists($title)
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Forgeting the Select/case syntax questions for now, has anyone solved this:

sshrum said:

"However, WinExists() is returning 0 even thou the window does exist.

If I do a WinWait() for the same window with the same params, WinWait returns 1"

"If WinWait can "see that window", then why can't WinExist?"

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

I'll pound my head on this some more...chances are I coded something wrong in there.

I'll trim it all the way down to a simple snippet (shoulda done this in the first place but the script is pretty small to begin with) and if I haven't found my coding error by then, I'll post it here.

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

I find that this works well:

$title = 'AutoIt v3.1.1 Setup'
Run(@ScriptDir & '\Autoit-v3.1.1.exe')

Dim $done
While Not $done
    Select
        Case WinExists( $title, 'Welcome to the AutoIt')
            ControlClick( $title, 'Welcome to the AutoIt', 1)
        Case WinExists( $title, 'If you accept the terms')
            ControlClick( $title, 'If you accept the terms', 1)
        Case WinExists( $title, 'Choose Install Location')
            ControlClick( $title, 'Choose Install Location', 1)
        Case WinExists( $title, 'Click Finish to close')
            ControlClick( $title, 'Click Finish to close', 1)
            $done = 1
        Case Else
            Sleep(250)
    EndSelect
WEnd

The Case Else ensures the sleep, if no other selection is true.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...