Jump to content

Recommended Posts

Posted

Hi All
I am trying to display a progress bar (or splash screen) while an EXE is being run and close it when the EXE stops running.
For example I am using the below code for two EXEs (in the same script)

;Run the uninstaller, display a progress bar while the uninstaller is running
Run("C:\Windows\temp\myprogram\uninstall.exe") 
ProgressOn("Uninstall MyProgram", "Waiting for the uninstaller to complete.", "0%")
For $i = 1 To 100 Step 1
   Sleep(50)
   ProgressSet($i, $i & "%")
Next
ProgressSet(100, "", "Complete")
Sleep(1000)
ProgressOff()


;Run the installer for My Program, display a progress bar while the installer is running
Run("C:\Windows\temp\myprogram\myinstall.exe") 
ProgressOn("Install MyProgram", "Waiting for the installer to complete.", "0%")
For $i = 1 To 100 Step 1
   Sleep(50)
   ProgressSet($i, $i & "%")
Next
ProgressSet(100, "", "Complete")
Sleep(1000)
ProgressOff()

 

If I use the RunWait then the progress bar displays after the EXE (uninstall OR myinstall) has completed. 

I can also increase the value of Sleep(50) but that would not be good.

So what would be the best way to display the progress bar while the EXE (uninstall.exe OR myinstall.exe) is running and close the progress bar when EXE stops running.

thanks 

Posted

Personally I use marquee style for installers that don't have an inbuilt progressbar, for example:

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

Local $hGUI = GUICreate("Example", 420, 60)
Local $idStatus = GUICtrlCreateLabel("Waiting for the installer to complete.", 10, 10, 400, 20)
Local $idProgress = GUICtrlCreateProgress(10, 30, 400, 20, $PBS_MARQUEE)
GUICtrlSendMsg($idProgress, $PBM_SETMARQUEE, True, 50)
GUISetState()

Local $iProcess = Run("Notepad.exe")
While ProcessExists($iProcess)
    Sleep(50)
WEnd
GUICtrlSetStyle($idProgress, $PBS_SMOOTH)
GUICtrlSetData($idProgress, 100)
GUICtrlSetData($idStatus, "Installation Complete")
Sleep(3000)

 

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