Jump to content
Sign in to follow this  
BryonR

Computer up time

Recommended Posts

BryonR

I'm trying to get the computer time in mins.

Share this post


Link to post
Share on other sites
Skrip

You can get the last boot time, then get the current time, then subtract it out.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites
Jos

Func PC_UPTIME()
    Local $day = ""
    Local $type = ""
    Local $hour = 0
    Local $min = 0
    Local $sec = 0
    Local $uptime
;
    $ret = DllCall("kernel32.dll", "long", "GetTickCount")
    If IsArray($ret) Then
        $msec = StringRight("00" & Mod($ret[0], 1000), 3)
        $uptime = Int($ret[0] / 1000)
        $sec = StringRight("00" & Mod($uptime, 60), 2)
        If $uptime >= 60 Then
            $uptime = Int($uptime / 60)
            $min = StringRight("00" & Mod($uptime, 60), 2)
            If $uptime >= 60 Then
                $uptime = Int($uptime / 60)
                $hour = StringRight("00" & Mod($uptime, 24), 2)
                If $uptime >= 24 Then; convert hours to days
                    $day = Int($uptime / 24)
                    $type = ""
                    If $day > 1 Then $type = "s"
                    $type = " Day" & $type & " "
                EndIf
            EndIf
        EndIf
        Return ($day & $type & $hour & ":" & $min & ":" & $sec)
    EndIf
EndFunc  ;==>PC_UPTIME


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Duijst

Func PC_UPTIME()
.....
EndFunc;==>PC_UPTIME
Thanks Jos, just what I needed.

Henk-Sjoerd.

Edited by Duijst

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  

×