TheCrimsonCrusader

How to have loop continue while running other programs

16 posts in this topic

I am wanting to create a simple software installer with a cheesy animated progress bar and a progress bar marking progress for a simple software installer.  Where I run into a problem is if I call the cheesy animated progress in a loop before the software installation calls, it will obviously be stuck in that loop and never actually run the rest of the code.

If I put it after the installation calls, then it won't run until after those installation calls are complete.  How do I have the cheesy animated progress continue to run until the last installation call is made?  For convenience of script testing, I just replaced software installation calls to just running notepad instead so after you close out one notepad, the next one opens up and the percentage moves up.

I'm sure it's something simple, but no clue on my part.  Thanks for any assistance!

 

#include <WindowsConstants.au3>


Opt("TrayMenuMode", 3) ;this is necessary to have system tray icon shown without menu options and to allow system tray bubble tips
Opt ("GUIOnEventMode", 1)
Opt("GUIResizeMode", 1)


Dim $SS_ETCHEDFRAME,$PBS_SMOOTH


GUICreate("Software Installation", 400, 420,-1,-1,$WS_MINIMIZEBOX)


GUICtrlCreateLabel("Progress:",1,225,100,20,$SS_ETCHEDFRAME,$WS_EX_DLGMODALFRAME)
GUICtrlSetFont (-1,-1, 800)
$progressbar = GUICtrlCreateProgress (100,225,25,20,BitOR($WS_EX_LAYERED,$PBS_SMOOTH))
$progressbarsteps = GUICtrlCreateProgress (162,225,231,20,BitOR($WS_EX_LAYERED,$PBS_SMOOTH))
$progresspercent = GUICtrlCreateLabel ("0%",125,225,37,20,$SS_ETCHEDFRAME,$WS_EX_DLGMODALFRAME)
GUICtrlSetFont (-1,-1, 800)


GUISetState()


;Cheesy animated progress
While 1
    Sleep(1000)
    GUICtrlSetData($progressbar, 0)
    GUICtrlSetData($progressbar, 100)
Wend


;Install applications one after another
$AppInstall1 = RunWait("notepad.exe")
GUICtrlSetData($progressbarsteps, 25)
GUICtrlSetData($progresspercent,"25%")
$AppInstall2 = RunWait("notepad.exe")
GUICtrlSetData($progressbarsteps, 50)
GUICtrlSetData($progresspercent,"50%")
$AppInstall3 = RunWait("notepad.exe")
GUICtrlSetData($progressbarsteps, 75)
GUICtrlSetData($progresspercent,"75%")
$AppInstall4 = RunWait("notepad.exe")
GUICtrlSetData($progressbarsteps, 100)
GUICtrlSetData($progresspercent,"100%")

 

Share this post


Link to post
Share on other sites



@TheCrimsonCrusader what are you trying to install, and why would you not do a silent installation rather than a "cheesy animated progress bar"?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@TheCrimsonCrusader what are you trying to install, and why would you not do a silent installation rather than a "cheesy animated progress bar"?

The install could be anything.  When installing MSIs, I would be installing them unattended/silent (/qn switch) and installation executables, I would be running those unattended/silent as well.  The purpose is just to have something animated, to show that the installation is in progress and that the machine or installation is not locked up.

Edited by TheCrimsonCrusader

Share this post


Link to post
Share on other sites

remove the while loop/

Then the small progress bar will only run once and won't be animated.  The intent is to have that go from 0% to 100% in a loop just to show that the operation is currently running and then the other progress is is the one that shows what actual percentage complete for all of the software installation steps.

Share this post


Link to post
Share on other sites

It sounds like you want the progress bar up and going as long as the installation is still running. By your statement above, it is going to go from 0 to 100, then starting over, until the install completes. Won't that irritate your users? Why not just install with /qb switch so the progress bar actually matches the installation?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

It sounds like you want the progress bar up and going as long as the installation is still running. By your statement above, it is going to go from 0 to 100, then starting over, until the install completes. Won't that irritate your users? Why not just install with /qb switch so the progress bar actually matches the installation?

 

I guess I am explaining it poorly. :-)

So when the GUI is opened with the current code.  It looks like this in terms of format:

A label called "Progress" followed by the Animated progress ($progressbar variable) followed by the progress percentage ($progresspercent variable) followed by the actual progress bar ($progressbarsteps variable)

The animated progress bar ($progressbar variable) is only 25x20 and just goes from 0% to 100% and back again in a loop.  This is my poor man's version of that little animated circle in today's modern Windows OSs that used to be the hour glass.  So it's small an unobtrusive.

Then to the right of that is the actual progress percentage followed by the progress bar.  All I am doing there is let's say there are 4 installs and I am doing them all silently, I am just doing application installation 1 and setting it to go to 25% after completion and then application installation 2 and setting that to 50% after completion and so on.

I don't want to use the QB switch as I want to hide the native installation progress and just use the static mechanism above.  It works, but I would like to have the animated progress bar that is just 25x20 going from 0% to 100% and back throughout the entire process until the last installation is complete.

 

 

Edited by TheCrimsonCrusader

Share this post


Link to post
Share on other sites

I don't get it, if each notepad represents an application installation, then removing the while loop does what you are describing.

If I remove the loop, those notepad call steps will run.  So the first notepad is ran and when I close that, it goes to 25%.  Then the next notepad is ran and when I close that, it goes to 50% and so on.  That part works.

However, by removing the loop, the small progress bar that goes from 0% back to 100% in a loop won't if I remove the loop obviously.  The intent of this is to have something moving at all times to let a user know that it is currently in the process of installing applications since some applications might take a long time to install and I don't want to rely on external progress bars such as the /QB switch for MSI installations.

Think of the small progress bar as just being a flashing text label instead that says "Installing..."  That's basically what I am wanting to accomplish.  Since I am having the main progress bar only increase in percentage after each install is done, I want something animated to make it look like it is doing something throughout the entire process..

Share this post


Link to post
Share on other sites

TheCrimsonCrusader,

The intent of this is to have something moving at all times to let a user know that it is currently in the process of installing

Use a marquee progress bar - that is why it exists:

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

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

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

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

Maybe another way to put it is I want something equivalent to this running while the installs are running:

http://zanstra.home.xs4all.nl/picks/progress.html

I just thought it an easier way would be to have a small progress bar running in a loop from 0% to 100% and back.

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

However, by removing the loop, the small progress bar that goes from 0% back to 100% in a loop won't if I remove the loop obviously.

Then the updating of that bar should be done within the functions which really installs these applications.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
#include <WindowsConstants.au3>


Opt("TrayMenuMode", 3) ;this is necessary to have system tray icon shown without menu options and to allow system tray bubble tips
Opt("GUIOnEventMode", 1)
Opt("GUIResizeMode", 1)


Dim $SS_ETCHEDFRAME, $PBS_SMOOTH


GUICreate("Software Installation", 400, 420, -1, -1, $WS_MINIMIZEBOX)


GUICtrlCreateLabel("Progress:", 1, 225, 100, 20, $SS_ETCHEDFRAME, $WS_EX_DLGMODALFRAME)
GUICtrlSetFont(-1, -1, 800)
$progressbar = GUICtrlCreateProgress(100, 225, 25, 20, BitOR($WS_EX_LAYERED, $PBS_SMOOTH))
$progressbarsteps = GUICtrlCreateProgress(162, 225, 231, 20, BitOR($WS_EX_LAYERED, $PBS_SMOOTH))
$progresspercent = GUICtrlCreateLabel("0%", 125, 225, 37, 20, $SS_ETCHEDFRAME, $WS_EX_DLGMODALFRAME)
GUICtrlSetFont(-1, -1, 800)


GUISetState()


;Cheesy animated progress
;While 1
;    Sleep(1000)
;    GUICtrlSetData($progressbar, 0)
;    GUICtrlSetData($progressbar, 100)
;Wend


;Install applications one after another
_Install()
GUICtrlSetData($progressbarsteps, 25)
GUICtrlSetData($progresspercent, "25%")
_Install()
GUICtrlSetData($progressbarsteps, 50)
GUICtrlSetData($progresspercent, "50%")
_Install()
GUICtrlSetData($progressbarsteps, 75)
GUICtrlSetData($progresspercent, "75%")
_Install()
GUICtrlSetData($progressbarsteps, 100)
GUICtrlSetData($progresspercent, "100%")

Func _Install()
    GUICtrlSetData($progressbar, 0)
    For $i = 1 To 100
        GUICtrlSetData($progressbar, $i)
        Sleep(10)
    Next

EndFunc   ;==>_Install

 


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Thank you, Melba.  That does the trick and is much easier.  I appreciate everyone's help on this!

Share this post


Link to post
Share on other sites

If all you want is a GIF animation like what you linked to, you can use Trancexx's GIFAnimation UDF:

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <FontConstants.au3>
#include <GIFAnimation.au3>

$sFilePath = @ScriptDir & "\blue-kiwi-zen-big.gif"
$hGUI = GUICreate("Please wait while we install your product", 250, 200,-1,-1,$WS_DLGFRAME)
GUISetBkColor ($COLOR_WHITE)
GUISetState(@SW_SHOW, $hGUI)

Global $hGIF = _GUICtrlCreateGIF($sFilePath, "", 60, 15)
GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

GUIDelete($hGUI)

 


√-1 2^3 ∑ π, and it was delicious!

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