LisHawj

How to call next function after completion of a loop?

7 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



LisHawj,

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

M23

 

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

@Melba23 quetion please?

If one were to use code like this?

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

Is this good practice?


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites

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

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Brilliant. Thank you


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites

@Melba23,

Thank you for your valued insights!  I like your marquee suggestion and will incorporate that into my production script for the home grown software installer.

Share this post


Link to post
Share on other sites

LisHawj,

My pleasure, as always.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

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