Sign in to follow this  
Followers 0
mdwerne

Calculate time logged on for that or a given day?

4 posts in this topic

#1 ·  Posted (edited)

Hello,

I was hoping for a hint in the right direction.

I'd like to write an app that looks at the local computers Security Event Log for Logon/Logoff events for the current user and display the sum amount of time for that day that the user has been logged on. I'm trying to get a feel for how much time I spend on the computer. My wife says it's much more than I believe it to be. I'd like to programatically prove her wrong.

Suggestions of which AutoIt functions etc...that I should look at would be a huge help.

Do any builtin functions read the Security log directly? I could probably figure out something from there.

Thanks!

-Mike

P.S. It would be extra cool if I/it could monitor in real time.

Edited by mdwerne

Share this post


Link to post
Share on other sites



umm start counter & display it in the corner of the screen while you are behind PC.

Enable it by CTRL + numpadsub

Write seconds hours days in ini file so if you hit enable again it will continue counting.

Disable it by CTRL + numpadadd


My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

@mdwerne - It would be easier just to keep track of your uptime and store the information in an .ini file. Here is a script I found on the forums:

MsgBox(0, "PC Uptime, So far",PC_UPTIME())

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
Your script would read the .ini for other uptime today, store the value in a variable, wait to capture a shutdown event, add the uptime to that original value found in the .ini file. Your script would also have to capture a change of day, if you work past midnight.

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

@goldenix & Squirrely1

Thanks for the suggestions!

I also located the "_EventLog__Read" function.

Between them all I think I'm good-to-go.

-Mike

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