Jump to content

How to handle a fork in the road


Recommended Posts

Alright, I have completed this script, and it works, but I know you guys could think of a better way to have handle this. When I run the setup for an add-in for Excel, if they already have a previous version of Excel, it initates the uninstall program for it, and then exits. If they do not have a version installed, it begins the install routine. Here's what I did:

$test = WinWait( "Confirm File Deletion", "Do you want", 30 )

If $test = 1 Then
    removeprevious()
ElseIf $test = 0 Then
    installnewone()
EndIf

And I created functions for removing the old one and installing the new one. At the end of the uninstall, I have a short sleep and then I have it run the installnewone function. This works, and works just fine, but doing the $test seems kinda...cheap? How would you have handled this differently/better?

TIA

Link to comment
Share on other sites

Guest Guest

Larry thanks for your reply. Can you quickly explain how AutoIt handles an "If WinWait" command. I have seen that used in other scripts, I just don't understand what your instructing AutoIt to do with that command. How do you "if wait" for a window? I was trying to get around the 30 second timeout if possible. I suppose I could do an "If WinExists Then blah" and "ElseIf WinExists blah". Now that I've thought about this I believe the "If WinWait" just means that if the the winwait succeeds in waiting for the window then do something. Is that correct?

Link to comment
Share on other sites

WinWait just waits for a window to be active, and the last parameter specifies a 30 second timeout. By embedding WinWait in an If-then statement, he is checking the return value for success (1) or failure/timeout (0).

Larry's code is a condensed version of the following:

$retValue = WinWait( "Confirm File Deletion", "Do you want", 30 )
If $retValue = 1 Then
    removeprevious()
Else;the $retValue was zero
    installnewone()
EndIf
Edited by CyberSlug
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

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