#cs ---------------------------------------------------------------------------- |
AutoIt Version: 3.3.12.0 |
Author: Connor Sheehan |
Script Function: |
Functions for a progress bar. |
@param $pid is the process ID for the installing program. Runs while the process exists |
@param $programName is the name of the program being installed |
@param $installDir is the directory of the install (no trailing backslash) |
@param $installSize is the program install size in bytes (right click install dir, check size) |
to use this script, import to the directory you are installing from |
and use this line: |
#include 'progBar_fxn.au3' |
#ce ---------------------------------------------------------------------------- |
#include <Math.au3> |
Func progressBar(Const$pid, Const$programName, Const$installDir, Const$installSize) |
;Get the size of the installation folder before adding any files |
$programFilesSize=DirGetSize($installDir) |
$progressBarMessage='Installing '&$programName |
;Activate the progressbar |
ProgressOn ( $programName, $progressBarMessage, 'Installing...' ) |
;While the install process exists run this loop |
WhileProcessExists ( $pid ) |
;check if our directory has grown to the size of the final installation |
;if the directory is not filled with installed files, calculate the % |
;completion and update the bar. |
$dirSize=DirGetSize ( $installDir ) |
$dirSize=$dirSize-$programFilesSize |
If$dirSize<$installSizeThen |
$percent=$dirSize*100/$installSize |
$percent= _Max ( _Min ( $percent, 99 ), 1 ) |
ProgressSet ( $percent ) |
EndIf |
Sleep ( 250 ) |
WEnd |
ProgressSet(100, 'Done') |
Sleep(3000) |
ProgressOff() |
EndFunc |
;This function provides a progress bar with no process id |
;Useful for when a program's installer is just calling other installers, so the process |
;you are trying to track is gone immediately |
Func progressBarNoPID(Const$programName, Const$installDir, Const$installSize) |
;Get the size of the installation folder before adding any files |
$programFilesSize=DirGetSize($installDir) |
$progressBarMessage='Installing '&$programName |
;Activate the progressbar |
ProgressOn ( $programName, $progressBarMessage, 'Installing...' ) |
;Loop until the program is installed |
Do |
;check if our directory has grown to the size of the final installation |
;if the directory is not filled with installed files, calculate the % |
;completion and update the bar. |
$dirSize=DirGetSize ( $installDir ) |
$dirSize=$dirSize-$programFilesSize |
If$dirSize<$installSizeThen |
$percent=$dirSize*100/$installSize |
$percent= _Max ( _Min ( $percent, 99 ), 1 ) |
ProgressSet ( $percent ) |
EndIf |
Sleep ( 250 ) |
Until$dirSize>=$installSize |
ProgressSet(100, 'Done') |
Sleep(3000) |
ProgressOff() |
EndFunc |