Jump to content

adjusting for conditional windows


Morris
 Share

Recommended Posts

I've found that installer behavior can be different based on a number of factors such as the other programs installed, previous versions, etc. I've tried to figure out conditional statements to adapt to multiple scenarios but the one I'm having trouble with is a conditional window (one that appears in some situations but not in others).

Typically, I have:

CODE
WinWait("Title1","Text1")

ControlClick("Title1","Text1","&Next >")

WinWait("Title2","Text2")

ControlClick("Title2","Text2","&Done")

But the problem arises when another window, say "Title1a", appears for some machines and not others. The second option would require code such as:

CODE
WinWait("Title1","Text1")

ControlClick("Title1","Text1","&Next >")

WinWait("Title1a","Text")

ControlClick("Title1a","Text","OK")

WinWait("Title2","Text2")

ControlClick("Title2","Text2","&Done")

What's a good way for accounting for both cases in one script when the middle window may never appear at all. A WinWait("") and a WinGetTitle("","") looped until either Title1a or Title2 are seen?

thanks,

JM

Link to comment
Share on other sites

How about AdlibEnabling an "If WinExists()"?

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

I've found that installer behavior can be different based on a number of factors such as the other programs installed, previous versions, etc. I've tried to figure out conditional statements to adapt to multiple scenarios but the one I'm having trouble with is a conditional window (one that appears in some situations but not in others).

Typically, I have:

CODE
WinWait("Title1","Text1")

ControlClick("Title1","Text1","&Next >")

WinWait("Title2","Text2")

ControlClick("Title2","Text2","&Done")

But the problem arises when another window, say "Title1a", appears for some machines and not others. The second option would require code such as:

CODE
WinWait("Title1","Text1")

ControlClick("Title1","Text1","&Next >")

WinWait("Title1a","Text")

ControlClick("Title1a","Text","OK")

WinWait("Title2","Text2")

ControlClick("Title2","Text2","&Done")

What's a good way for accounting for both cases in one script when the middle window may never appear at all. A WinWait("") and a WinGetTitle("","") looped until either Title1a or Title2 are seen?

thanks,

JM

I had a similar problem automating an installation of WinZip. Try using the timeout on WinWaitActive to wait a brief time for the conditional window. If it doesn't appear in a set time (e.g. 5 sec), continue the script.

Link to comment
Share on other sites

@Morris,

Welcome to the forums...

If I might elaborate on what mikehunt114 has suggested?

Please wade thru the code and comments in this post:

http://www.autoitscript.com/forum/index.ph...st&p=267303

...and then a better solution using adlib in this post:

http://www.autoitscript.com/forum/index.ph...st&p=267688

Those posts might give you some ideas...

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

Link to comment
Share on other sites

How about this thing?

WinWaitNew_GetTitle, WinWaitActive and GetTitle on unknown language computer

If you are sure something is going to come up you can catch the title of the new window with this.

Well, this is a bit dodgy solution, I wanted just quick. It is also possible to get the handles and then Window Text as well by rewriting the loop to use arrays. That probably would be faster even.

Combination of this with some timeout you can have the job done.

I can not think of other solution of "no new window came up" state other than timeout.

Link to comment
Share on other sites

Adding to what has been posted (and working from the top of my head)

You might be able to use something like this

$T_Ttl = WinGetTitle("","")

If StringInStr($T_Ttl, "Title1a") Then

Do_This()

Else

Do_SomethingElse()

EndIf

One word of caution... WinTitles are case sensitive

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Ah. Thank you very much. I do not want to rely on Sleeps or timeouts as my scripts run on a wide variety of hardware, making timing issues troublesome.

I did not know about Adlib so thank you Mikehunt (and Herewasplato for the clarification). Here is the new code, which installs beautifully and I think has the logic I was trying to implement. This situation arises with several of my programs so now I can make smarter scripts:

WinWait("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","Welcome to the InstallShield Wizard for GeoDa")
ControlClick("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","Welcome to the InstallShield Wizard for GeoDa","&Next >")
    
WinWait("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","License Agreement")
ControlCommand("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","License Agreement","Button3","Check","")
ControlClick("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","License Agreement","&Next >")
    
WinWait("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","Destination Folder")
ControlClick("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","Destination Folder","&Next >")
    
WinWait("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","Database Folder")
ControlClick("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","Database Folder","&Next >")
    
WinWait("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","Setup Type")
ControlClick("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","Setup Type","&Next >")
    
WinWait("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","Ready to Install the Program")
ControlClick("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","Ready to Install the Program","&Install")
    
; in case of 'failed to register' window
AdlibEnable("_Adlib")
    
WinWait("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","InstallShield Wizard Completed")
ControlClick("GeoDa 0.9.5-i (Beta) - InstallShield Wizard","InstallShield Wizard Completed","&Finish")
    
AdlibDisable()

...

Func _Adlib()
    If WinExists("GeoDa 0.9.5-i (Beta) Installer Information", "Error 1904") Then
        ControlClick("GeoDa 0.9.5-i (Beta) Installer Information", "Error 1904","&OK")
    EndIf
EndFunc

If the "Install Wizard Complete" window appears then I know the error will not appear.

JM

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...