Sign in to follow this  
Followers 0
blazz0r

If nested in a while loop strangeness

3 posts in this topic

I'm executing a script that checks for a window, and if there performs an action then closes the entire process. For some reason though when I added an IF conditional nested within an While statement it broke the script.

When running the script it now says that the "WEnd" statement with no matching "While" statement. The syntax appears correct to me (I've been scripting for 2 years and programming for 4).

Could someone take a look at this and see what's up?

Opt("WinTitleMatchMode", 2)

While WinExists("- Microsoft Virtual PC 2004") 
    Run("C:\Program Files\Microsoft Virtual PC\Virtual PC.exe")
    WinWaitActive("Virtual PC Console")
    Send("!a")
    Send("c")
    If WinExists("", "What do you want the virtual machine to do?") Then
      WinActivate("", "What do you want the virtual machine to do?")
      $CloseTxt = WinGetText("Close")
      While NOT StringInStr($CloseTxt, "Turns off virtual machine and saves all changes.") 
        Send("t")
        $CloseTxt = WinGetText("", "What do you want the virtual machine to do?")
      WEnd
      Send("{ENTER}")
    End If
Wend

ProcessClose("Virtual PC.exe")

Share this post


Link to post
Share on other sites



End If should be EndIf.

Share this post


Link to post
Share on other sites

End If should be EndIf.

Thanks Helge, guess I've been using VBS a bit much lately.

Share this post


Link to post
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
Sign in to follow this  
Followers 0