Guest jmaclaurin Posted August 23, 2005 Posted August 23, 2005 I have written an install script that is working ok, except that with some installs, an additional window appears. I can capture the window that appears and send a statement to close it, but it doesn't always appear so I assume I need an IF statement. Here is the original script. Run("WSFTP_ProEC_Install.exe") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Welcome to the InstallShield Wizard for Ipswitch WS_FTP Professional") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "License Agreement") Send("!a") WinWaitActive ("Ipswitch WS_FTP Professional 9", "License Agreement") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Choose Destination Location") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Select Program Folder") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Start Copying Files") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "InstallShield Wizard Complete") Send("{SPACE}") Send("{ENTER}") Here is what I need to add. WinWaitActive ("Reboot required", "Another setup has requested a reboot.") Send("y") How do I add the condition?
GaryFrost Posted August 23, 2005 Posted August 23, 2005 Look up AdlibEnable and WinExists SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Josbe Posted August 23, 2005 Posted August 23, 2005 AdLib gives you a solution. Read the reference about this and check the small example included (waiting for a window) and then apply to your script. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
seandisanti Posted August 23, 2005 Posted August 23, 2005 I have written an install script that is working ok, except that with some installs, an additional window appears. I can capture the window that appears and send a statement to close it, but it doesn't always appear so I assume I need an IF statement.Here is the original script.Run("WSFTP_ProEC_Install.exe") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Welcome to the InstallShield Wizard for Ipswitch WS_FTP Professional") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "License Agreement") Send("!a") WinWaitActive ("Ipswitch WS_FTP Professional 9", "License Agreement") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Choose Destination Location") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Select Program Folder") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Start Copying Files") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "InstallShield Wizard Complete") Send("{SPACE}") Send("{ENTER}")Here is what I need to add.WinWaitActive ("Reboot required", "Another setup has requested a reboot.") Send("y")How do I add the condition?<{POST_SNAPBACK}>presumably that window pops up at the time when another could pop up. typically what i do in situations is something like:while 1 if winexists("goodwin") then ... exitloop endif if winexists("badwin") then ... exitloop endif sleep(100) wendtaht will just check until either of the possible windows appears, deal with the one that shows up, and continue on to the next window (presumably the same after either). if the badwindow shows up, then the good one... you may want to move the if statement handling the bad window above the good window handler and remove the exitloop statement. that way once the bad window is handled and the good window appears, it is still handled before the while exits...
GaryFrost Posted August 23, 2005 Posted August 23, 2005 @cameronsdad it would be much better in this case to use the Adlib, it keeps checking for the window and allows the rest of your script to continue processing. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
seandisanti Posted August 23, 2005 Posted August 23, 2005 (edited) @cameronsdad it would be much better in this case to use the Adlib, it keeps checking for the window and allows the rest of your script to continue processing.<{POST_SNAPBACK}>better is a subjective term, but i disagree because: with a linear script (like this one) that handles each window as it comes up, there is no reason to check for the window before it is possible to exist. at that point you are running checks that aren't necessary every X ms. as far as the script continuing to process, if the window pops up at a specific point, why would i want to check before or after that point? for this type of case, it seems that adlib is inefficient causing extra checks throughout when only a few loops at the proper point are really necessary.***edit*** fixed typo Edited August 23, 2005 by cameronsdad
Guest jmaclaurin Posted August 24, 2005 Posted August 24, 2005 AdLib gives you a solution. Read the reference about this and check the small example included (waiting for a window) and then apply to your script.<{POST_SNAPBACK}>I am trying what you have suggested but I don't think I have the syntax correct.Run("WSFTP_ProEC_Install.exe") AdlibEnable("myadlib") ;... Exit Func myadlib() If WinActive("Reboot required") Then Send("y") ;... EndIf EndFunc WinWaitActive ("Ipswitch WS_FTP Professional 9", "Welcome to the InstallShield Wizard for Ipswitch WS_FTP Professional") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "License Agreement") Send("!a") WinWaitActive ("Ipswitch WS_FTP Professional 9", "License Agreement") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Choose Destination Location") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Select Program Folder") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Start Copying Files") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "InstallShield Wizard Complete") Send("{SPACE}") Send("{ENTER}")
seandisanti Posted August 24, 2005 Posted August 24, 2005 I am trying what you have suggested but I don't think I have the syntax correct.Run("WSFTP_ProEC_Install.exe") AdlibEnable("myadlib") ;... Exit Func myadlib() If WinActive("Reboot required") Then Send("y") ;... EndIf EndFunc WinWaitActive ("Ipswitch WS_FTP Professional 9", "Welcome to the InstallShield Wizard for Ipswitch WS_FTP Professional") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "License Agreement") Send("!a") WinWaitActive ("Ipswitch WS_FTP Professional 9", "License Agreement") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Choose Destination Location") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Select Program Folder") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Start Copying Files") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "InstallShield Wizard Complete") Send("{SPACE}") Send("{ENTER}")<{POST_SNAPBACK}>remove the ;... Exitthe ";..." is to mean that your code goes there, and the 'Exit' is for the end of the script. the way you have it at the top like that makes it exit out of the script before it does anything.
Guest jmaclaurin Posted August 24, 2005 Posted August 24, 2005 First off, thanks everyone for your help. This is the first time I have used this and your help is making it much easier to learn. I think I almost have it, but I am having problems with having multiple "IF" and multiple ADLIB. Note that myadlib2 is a repeat of the first, but when I run the second exe, neither myadlib work for that section. expandcollapse popupRun("WSFTP_ProEC_Install.exe") AdlibEnable("myadlib") Func myadlib() If WinActive("Reboot required") Then Send("y") EndIf If WinActive("Ipswitch WS_FTP Professional 9", "Maintenance Complete") Then Send("{DOWN}") Send("{ENTER}") EndIf EndFunc WinWaitActive ("Ipswitch WS_FTP Professional 9", "Welcome to the InstallShield Wizard for Ipswitch WS_FTP Professional") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "License Agreement") Send("!a") WinWaitActive ("Ipswitch WS_FTP Professional 9", "License Agreement") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Choose Destination Location") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Select Program Folder") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Start Copying Files") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "InstallShield Wizard Complete") Send("{SPACE}") Send("{ENTER}") SLEEP 5000 Run("wsftp_pro901.exe") Func myadlib2() If WinActive("Reboot required") Then Send("y") EndIf EndFunc WinWaitActive ("Ipswitch WS_FTP Professional 9.01", "Welcome") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9.01", "Start Copying Files") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9.01", "Update Complete") Send("{ENTER}") EXIT
Gigglestick Posted August 24, 2005 Posted August 24, 2005 If you know that the reboot question happens after the Update Complete dialog and probably within, say, 10 seconds, then use this just before you exit: If WinWaitActive ("Reboot required", "Another setup has requested a reboot.", 10) Then Send("y") My UDFs: ExitCodes
seandisanti Posted August 24, 2005 Posted August 24, 2005 First off, thanks everyone for your help. This is the first time I have used this and your help is making it much easier to learn.I think I almost have it, but I am having problems with having multiple "IF" and multiple ADLIB.Note that myadlib2 is a repeat of the first, but when I run the second exe, neither myadlib work for that section.expandcollapse popupRun("WSFTP_ProEC_Install.exe") AdlibEnable("myadlib") Func myadlib() If WinActive("Reboot required") Then Send("y") EndIf If WinActive("Ipswitch WS_FTP Professional 9", "Maintenance Complete") Then Send("{DOWN}") Send("{ENTER}") EndIf EndFunc WinWaitActive ("Ipswitch WS_FTP Professional 9", "Welcome to the InstallShield Wizard for Ipswitch WS_FTP Professional") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "License Agreement") Send("!a") WinWaitActive ("Ipswitch WS_FTP Professional 9", "License Agreement") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Choose Destination Location") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Select Program Folder") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Start Copying Files") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "InstallShield Wizard Complete") Send("{SPACE}") Send("{ENTER}") SLEEP 5000 Run("wsftp_pro901.exe") Func myadlib2() If WinActive("Reboot required") Then Send("y") EndIf EndFunc WinWaitActive ("Ipswitch WS_FTP Professional 9.01", "Welcome") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9.01", "Start Copying Files") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9.01", "Update Complete") Send("{ENTER}") EXIT<{POST_SNAPBACK}>i still stand by my previous suggestion and think that an adlib is not the best way to go for you. That being said, 2 adlib functions are unnecessary as the statements from both could just be put into one. your if statements look fine, but you're assuming that the result window will be made active, which is not always the case either because of user interaction, or because sometimes things just don't work the way you expect. you may want to check if they exist rather than if they're active.
Guest jmaclaurin Posted August 25, 2005 Posted August 25, 2005 Almost got it..... The adlib worked for the first reboot message, but I couldn't get it to work for the second. So I opted for a while statement, but can't get it to work either. expandcollapse popupRun("WSFTP_ProEC_Install.exe") AdlibEnable("myadlib") Func myadlib() If WinActive("Reboot required", "Another setup has requested a reboot.") Then Send("y") EndIf EndFunc WinWaitActive ("Ipswitch WS_FTP Professional 9", "Welcome to the InstallShield Wizard for Ipswitch WS_FTP Professional") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "License Agreement") Send("!a") WinWaitActive ("Ipswitch WS_FTP Professional 9", "License Agreement") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Choose Destination Location") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Select Program Folder") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9", "Start Copying Files") Send("!n") while 1 if winexists("Ipswitch WS_FTP Professional 9", "The InstallShield Wizard has successfully installed Ipswitch WS_FTP Professional. Before you can use the program, you must restart your computer.") Then Send("{DOWN}") Send("{ENTER}") exitloop endif If WinExists("Ipswitch WS_FTP Professional 9", "The InstallShield Wizard has successfully installed Ipswitch WS_FTP Professional. Click Finish to exit the wizard.") Then Send("{SPACE}") Send("{ENTER}") exitloop endif sleep(100) wend sleep(5000) Run("wsftp_pro901.exe") while 2 if winexists("Reboot required", "Another setup has requested a reboot.") Then Send("y") exitloop endif sleep(100) wend WinWaitActive ("Ipswitch WS_FTP Professional 9.01", "Welcome") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9.01", "Start Copying Files") Send("!n") WinWaitActive ("Ipswitch WS_FTP Professional 9.01", "Update Complete") Send("{ENTER}") EXIT
seandisanti Posted August 25, 2005 Posted August 25, 2005 (edited) are you sure it's the adlib function that worked? you have a while statement that checks if the winexists and does what you want. that will only work once, because you're exiting that loop once it happens. to check if it's the adlib or while function that's actually working the way it's supposed to....actually let me rephrase that, working the way you intend it to, add a msgbox before your exitloop. like msgbox(0,"reboot window found","by while loop"). if you see the msgbox, then you know that the problem is that the adlib didn't catch it, and your issue isn't that the adlib only works once, it's that you're not using enough while loops. (one at each point where the reboot window may pop up) if you don't see the message but the first reboot window is dealt with correctly, then there's a different issue. ***edit*** too many words... Edited August 25, 2005 by cameronsdad
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now