Sign in to follow this  
Followers 0
Draygoes

get system uptime

4 posts in this topic

Hello. Could someone please give me an example of how to get the system uptime. I mean hour/min/sec format.

Is that even possible???


Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites



Thank you. I just have one more question. How would I display this in the form of a message box?

Sorry. I have no experience with working with arrays...


Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thank you. I just have one more question. How would I display this in the form of a message box?

Sorry. I have no experience with working with arrays...

I added this to SmOke_N's topic in Examples:

A General Support user was looking for reformatting of the output, and since the output is already going through a lot of formatting, I did a mod to give different formats out on an input flag: 0 = array, 1 = integer, 2 = string:

#include <array.au3> ; Only for _ArrayDisplay() in demo

; Default ($iFlag = 0)
$aArray = _TimeSystemRestart()
_ArrayDisplay($aArray, 'Return Info')

; $iFlag = 1
$iTime = _TimeSystemRestart(1)
MsgBox(64, "Return Info", $iTime & " millisecs")

; $iFlag = 2
$sTime = _TimeSystemRestart(2)
MsgBox(64, "Return Info", "Uptime: " & $sTime)

; =========================================================================
; Function _TimeSystemRestart()
; Returns system up time
;   $iFlag:
;       0 (default) Returns array:
;           [0] = 5; [1] = Wks; [2] = Days; [3] = Hrs; [4] = Mins; [5] = Secs
;       1 Returns integer raw ticks (total millisecs)
;       2 Returns string formatted WW:DD:HH:MM:SS
; Authors:  Function by SmOke_N, mod by PsaltyDS
; =========================================================================
Func _TimeSystemRestart($iFlag = 0)
    Local $iSubTotal = DllCall('kernel32.dll', 'int', 'GetTickCount')
    If Not IsArray($iSubTotal) Then Return SetError(1, 0, 0)
    If $iFlag = 1 Then Return $iSubTotal[0]
    $iSubTotal = $iSubTotal[0] / 1000
    Local $iWeek = Int(($iSubTotal / 604800))
    If $iWeek > 0 Then $iSubTotal -= $iWeek * 604800
    Local $iDay = Int(($iSubTotal / 86400))
    If $iDay > 0 Then $iSubTotal -= $iDay * 86400
    Local $iHour = Int(($iSubTotal / 3600))
    Local $iMin = Int(($iSubTotal - ($iHour * 3600)) / 60)
    Local $iSec = Int(($iSubTotal - $iHour * 3600) - ($iMin * 60))
    Local $sRET = StringFormat('%02d', $iWeek) & ':' & $iDay & ':' & StringFormat('%02d', $iHour) & ':' & _
            StringFormat('%02d', $iMin) & ':' & StringFormat('%02d', $iSec)
    If $iFlag = 2 Then Return $sRET
    Return StringSplit($sRET, ':')
EndFunc   ;==>_TimeSystemRestart
<_< Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  
Followers 0