Jump to content
Sign in to follow this  

Showing Elapsed Time while using Run/Runwait

Recommended Posts

Hi folks,

I've created a progressbar function and I want to show users how long the script has been running.

I currently have it showing the actual progress bar (of course), The time the script started, The current time, and the elapsed time and the current action.

Problem is: The current time and elapsed time get calculated when the function is called, and I'd prefer to have them update in realtime. Is that possible?

Here's the gist of my script:

Func InstallThis($app, $params)

   RunWait(@comspec & "/c" & @scriptdir & "\" & $app & " " & $params)
   _ShowProgress("Now installing " & $app)


Func _ShowProgress($msg)
    Local $RunTimeSeconds = 0
    Local $RunTimeMinutes = 0
    Local $RunTimeHours = 0
    $CompletedFunctionCalls = $CompletedFunctionCalls + 1
    $i = Int(($CompletedFunctionCalls / $TotalFunctionCalls) * 100)
    $RunTimeSeconds =  _DateDiff("s", $StartTime, _NowCalc())
    If ($RunTimeSeconds > 59) Then
        While $RunTimeSeconds > 59
            $RunTimeSeconds = $RunTimeSeconds - 60
            $RunTimeMinutes = $RunTimeMinutes + 1
            If $RunTimeMinutes > 59 Then
                $RunTimeMinutes = $RunTimeMinutes - 60
                $RunTimeHours = $RunTimeHours + 1
    ProgressSet( $i, "Time is now " & _NowTime() & ". Elapsed time: " & $RunTimeHours & "h:" & $RunTimeMinutes & "m:" & $RunTimeSeconds & "s. " & @LF _
                & $i & " percent complete. Please be patient..." & @LF _
                & $msg)

EndFunc ;==>_ShowProgress

Make sense?

Edited by nikink

Share this post

Link to post
Share on other sites

The only way I can think of to do it is to use Run() instead of RunWait() and then loop until the install is finished, updating every 500ms or so. Something like:

$pid = Run("whatever.exe")
While ProcessExists($pid)
    _ShowProgress("Now installing " & $app)
MsgBox(64, "Done!", "Installation of " & $app & " is finished!")

Share this post

Link to post
Share on other sites

Local $time = 0
RunWait(....x.....x..x.x..x..xx...) ; ^^
While ProcessExists(....x...x)
$time = $time + 1
MsgBox(0,"", Time running was " & $time/1000 )

Maybe this works :)

--------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote]

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
Sign in to follow this  

  • Create New...