Jump to content

If nested in a while loop strangeness


Recommended Posts

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