prp2 0 Posted September 14, 2007 Ok, so I'm making a script to install a program for me which I can then deploy on multiple machines easily. Some of the machines I'd be using it on may already have an older version of the program installed, so I will force a reinstall. What I get presented with are a different set of Windows at the beginning, after which the regular setup continues. What I'm trying to do is simply account "If this window comes up, do this. Otherwise, do that." It works, but only if one or the other comes first in my script. Meaning if I have the reinstall code first and run the script on a machine that would do a reinstall, it works. If I run it as new, it doesn't work. I'm probably just overlooking a simple Else or ElseIf somewhere, but I can't figure out where. Any thoughts? I tried searching for examples of what I'm trying to do and found none. ; Setup with customized settings ; Is this a reinstall? If WinWait("Reinstallation", "If you wish to reinstall") Then If Not WinActive("Reinstallation", "If you wish to reinstall") Then WinActivate("Reinstallation Wizard", "If you wish to reinstall") WinWaitActive("Reinstallation", "If you wish to reinstall") ControlClick("Reinstallation", "If you wish to reinstall", 1013) Sleep(2) ControlClick("Reinstallation", "If you wish to reinstall", 1002) Sleep(2) ControlClick("Reinstallation", "If you wish to reinstall", 12324) Else ; It's not a reinstall, proceed normally WinWait("Setup Wizard", "Welcome to Setup") If Not WinActive("Setup Wizard", "Welcome to Setup") Then WinActivate("Setup Wizard", "Welcome to Setup") WinWaitActive("Setup Wizard", "Welcome to Setup") ControlClick("Setup Wizard", "Welcome to Setup", 1002) Sleep(2) ControlClick("Setup Wizard", "Welcome to Setup", 12324) ; License agreement WinWait("End-user Software License Agreement", "SOFTWARE LICENSE AGREEMENT") If Not WinActive("End-user Software License Agreement", "SOFTWARE LICENSE AGREEMENT") Then WinActivate("End-user Software License Agreement", "SOFTWARE LICENSE AGREEMENT") WinWaitActive("End-user Software License Agreement", "SOFTWARE LICENSE AGREEMENT") ControlClick("End-user Software License Agreement", "SOFTWARE LICENSE AGREEMENT", 1011) Sleep(2) ControlClick("End-user Software License Agreement", "SOFTWARE LICENSE AGREEMENT", 12324) ; Destination folder WinWait("Select destination folder", "Select folder") If Not WinActive("Select destination folder", "Select folder") Then WinActivate("Select destination folder", "Select folder") WinWaitActive("Select destination folder", "Select folder") ControlClick("Select destination folder", "Select folder", 12324) EndIf Share this post Link to post Share on other sites
SmOke_N 211 Posted September 14, 2007 If Reinstallation window never exists, then you'll never get past the first "If" statement (winwait) because there is no time to timeout on. Maybe try something like:; Is this a reinstall? WinWait("Reinstallation", "", 10);Wait 10 seconds before failing If WinExists("Reinstallation") Then ;rest Else ;other EndIf Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Share this post Link to post Share on other sites
prp2 0 Posted September 14, 2007 (edited) Would that apply even though I have a delay defined at the top? Opt("WinWaitDelay", 100) Edit -- Ahh, evidently it would, because that worked. Thanks! Edited September 14, 2007 by prp2 Share this post Link to post Share on other sites