Jump to content
Sign in to follow this  

Progress Bar in loop only displays once

Recommended Posts


Can someone tell me what I am doing wrong? I need help understanding why the "ReStart" progress bar only displays the first time it is run and not any other time (lines 79-91). It used to run perfectly until I decided to get fancy and put in the countdown.

; Launch Citrix Application and wait for it to timeout after 8 hours then relaunch it repeat process three times then reboot computer.
; AutoIt Version: 3.0
; Language:       English

; Set the Username and Password to variables
$MilleUsername = "username"
$MillePassword = "password"

;Citrix Application Variables: 
$ProgramFiles = @ProgramFilesDir
$PNAgent = "\Citrix\ICA Client\pnagent.exe"
$QLaunchSwitch = "/QLaunch"
$QLaunchArgument = "BH45D:Emergency Room Monitor" ;Published Application Name
$QuoteCharacter = Chr(34)

;Progress bar time variables: 
$InitialProgressBarTimeOut = 10 ;Seconds
$RestartProgressBarTimeOut = 5 ;Seconds
$InitialProgressBarStep = (100 / $InitialProgressBarTimeOut)
$SecondProgressBarStep = (100 / $RestartProgressBarTimeOut)
$CountDown1 = $InitialProgressBarTimeOut
$CountDown2 = $RestartProgressBarTimeOut

; Establish the counter and Set number of times to loop
$count = 0
$loop_length = 3 ;Loop three times to restart the timed out Citrix Application then reboot computer.

        While $Countdown1 > 0
        ProgressOn("", "ER Monitor Starting in " & $InitialProgressBarTimeOut & " Seconds", "")
            For $i = 1 to 100 step $InitialProgressBarStep          
                    ProgressSet( $i, "Please Wait!", " ER Monitor Starting in " & $Countdown1 & " Seconds")
             $Countdown1 = $Countdown1 - 1
        ProgressSet(100 , "Done", "Complete")

;Execute the loop "While" the $count is less than zero
While $count < $loop_length
    ; Increase the count by one
    $count = $count + 1

;Launch Citrix from the program files folder. :
    Run($ProgramFiles & $PNAgent & " " & $QLaunchSwitch & " " & $QuoteCharacter & $QLaunchArgument & $QuoteCharacter)
    ;MsgBox(8192, "Citrix path:", $ProgramFiles & $PNAgent & " " & $QLaunchSwitch & " " & $QuoteCharacter & $QLaunchArgument & $QuoteCharacter)

    If @error Then
        ; A message box that lets the user know the script failed when launching the application and Exit Script.
        MsgBox(16, "AutoIt ER Monitor Script", "Failed when launching ER Monitor application.  Script Closed")

    ; Wait for the Log On to become active
    WinWaitActive("ER Logon - \\Remote")

    ; Log On with Username and Password set above
        Send( $MilleUsername & @TAB & $MillePassword & @TAB & @CR )

    ; Wait for the ER Application and Available Provider window to become active
        WinWaitActive("ER Monitorview, Emergency", "", 1)

    ;Wait 5 Seconds for Application to fully load

    ;Press the ALT key on the keyboard and then choose List which is the second (L) on menubar and Show Board which is the second (S) in the dropdown menu.
        Send( "{ALT}" & "L" & "L"  )
        Send( "S" & "S"  )
    ;Wait until the ER Monitor is closed
    WinWaitClose("ER Monitorview, Emergency")
    ; If the loop is going to continue then wait
        If $count < $loop_length Then
            While $Countdown2 > 0
            ProgressOn("", "ER Monitor Restarting in " & $RestartProgressBarTimeOut & " Seconds", "")
                For $i = 1 to 100 step $SecondProgressBarStep           
                    ProgressSet( $i, "Please Wait!", "ER Monitor Restarting in " & $Countdown2 & " Seconds")
                $Countdown2 = $Countdown2 - 1
            ProgressSet(100 , "Done", "Complete")

Wend  ; End While

;Force a reboot


Share this post

Link to post
Share on other sites

I would say try adding in a line between the wend and endif to reset the $CountDown2 variable. My assumption is that because it is global, once it reaches 0 it stays recorded as 0 because there is nothing else to tell it otherwise.



My Android cat and mouse game

We're gonna need another Timmy!

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.