Jump to content

Recommended Posts

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
  • Moderators
Posted

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:

  Reveal hidden contents

 

Posted

@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?

  • Moderators
Posted

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:

  Reveal hidden contents

 

Posted

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

  • Moderators
Posted

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:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...