Jump to content

How to call next function after completion of a loop?


Recommended Posts

I am working with a piece of home grown software that does not have an installation status/notification and takes about 45-60 minutes to install (silent install without any visual cues).  The only way I can tell when the software has completed installation is to search for its process name.  I quickly wrote up the following script to give me a visual cue  that the installation is ongoing ( a looping progress bar effect).  Upon finding the process, the visual cue (progress bar complete and closes out).  I am using Notepad.exe to test it.  The codes get stuck and does not execute the codes below the While Loop.  Your help is appreciated and thanks for your time.

Status()

Func Status()
    ProgressOn("Notepad Test", "Testing Progress Bar...", "")

    While 1
        For $i = 0 To 100 Step 5
            Sleep(1000)
            If Not ProcessExists("notepad.exe") Then
                ProgressSet($i)
            ElseIf ProcessExists("notepad.exe") Then
                ProgressSet(100, "", "Notepad.exe Exists!")
                Sleep(5000)
                ProgressOff()
            EndIf
        Next
    WEnd
    
   If ProcessExist($sHarvest_exe) Then
   ; more codes here
   ; more codes here
   ; more codes here
   ;End codes
   Call("stop")
EndFunc   ;==>Status

Func Stop()
    MsgBox(0, "", "Testing completed!")
    Exit
EndFunc   ;==>Stop

 

Edited by LisHawj
Link to comment
Share on other sites

  • Moderators

LisHawj,

You need to add an "ExitLoop 2" after closing the Progress,  otherwise you just remain within the loops.

M23

 

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Skysnake,

I would say not. If there is one simple condition to be met then I would use a Do...Until loop:

Local $x = 1
Do
    ; do something
    
    ; If condition is met then
    $x = 0 ; --> exit the loop?
Until $x = 0

In the OP's case I would not use the built-in Progress* functions at all - I would simplify the whole thing by using a custom marquee progressbar along with a Do...Until loop:

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>

Status()

Func Status()
    $hGUI = GUICreate("Test", 500, 50)
    GUICtrlCreateProgress(10, 10, 480, 20, $PBS_MARQUEE)
    GUICtrlSendMsg(-1, $PBM_SETMARQUEE, True, 50) ; final parameter is update time in ms
    GUISetState()

    Do
        Sleep(1000)
    Until ProcessExists("notepad.exe")

    GUIDelete($hGUI)

    MsgBox(0, "", "Testing completed!")

EndFunc   ;==>Status

The marquee progress is designed for events when the timing is uncertain - and "45-60 minutes" certainly falls into that category!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

LisHawj,

My pleasure, as always.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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