Sign in to follow this  
Followers 0
nicoco

recording active windows for time tracking

6 posts in this topic

Hi,

I've done small useless stuff with auto-it before,

now I'd like to do something that would help me track my time :

how much time I spend reading/writing emails

how much time I spend on the web browser

how much time I spend ... actually working :)

So my idea is to log in a file when the title of a window when it becomes active, and inactive

then I'll be able to make statistics :mellow:

any leads on how to do this?

if it's not possible do you know any software that does this?

Thanks,

Nicoco

Share this post


Link to post
Share on other sites



Hi,

I've done small useless stuff with auto-it before,

now I'd like to do something that would help me track my time :

how much time I spend reading/writing emails

how much time I spend on the web browser

how much time I spend ... actually working :)

So my idea is to log in a file when the title of a window when it becomes active, and inactive

then I'll be able to make statistics :mellow:

any leads on how to do this?

if it's not possible do you know any software that does this?

Thanks,

Nicoco

Be careful to word what you mean specifically here... Do you want 'Active' Windows Logged or When a Visible Window Exists?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Be careful to word what you mean specifically here... Do you want 'Active' Windows Logged or When a Visible Window Exists?

By active window I mean the window that has the focus.

Example : Now I'm replying to this message in firefox, when i'll do alt-tab to switch back to crimson editor, I'd like to have a new line in a log file with the time and 'CrimsonEditor' (and the full title for info on what i'm working on), then when I switch to outlook, another line in the log file, etc.

At the end of the day, I'd like to see something like

start;stop;app;full title

10-mar-2006@10:15:51;10-mar-2006@10:16:12;Outlook;blah

10-mar-2006@10:16:12;10-mar-2006@10:45:08;Firefox;AutoIt Forums

10-mar-2006@10:45:08;10-mar-2006@10:55:18;CrimsonEditor;C:\dev\src\Main.java

10-mar-2006@10:55:18;10-mar-2006@10:56:58;Firefox;New York Times

etc...

Now, what I want to find out is how to detect the change of window focus, the rest is not very difficult

Edited by nicoco

Share this post


Link to post
Share on other sites

Oh, dunno about this timing stuff. :)

Have a play with this.

While 1
    $title = WinGetTitle('')
    MsgBox(0, '', $title)
    Sleep(1000)
WEnd

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

This needs some tweaking:

Global $Begin = 1, $ActiveTime = '', $TrapTitle = '', $DeActiveTime = ''
HotKeySet('{ESC}', 'EXITTRACK')
AdlibEnable('KeepTrackOfWindows', 250)

While 1
    Sleep(1000)
WEnd

Func KeepTrackOfWindows()
    Local $w_WinList = WinList()
    For $i = 1 to $w_WinList[0][0]
        If $w_WinList[$i][0] <> "" AND BitAnd(WinGetState($w_WinList[$i][1]), 10) Then 
            $ActiveWindow = $w_WinList[$i][0]
            ExitLoop
        EndIf
    Next
    If $Begin = 1 Then
        $TrapTitle = $ActiveWindow
        $ActiveTime = @MDAY & '-' & @MON & '-' & @YEAR _ 
        & '@' & @HOUR & ':' & @MIN & ':' & @SEC & ';'
        $Begin = 2
    ElseIf $TrapTitle <> $ActiveWindow And $TrapTitle <> '' Then
        $DeActiveTime = @MDAY & '-' & @MON & '-' & @YEAR _ 
        & '@' & @HOUR & ':' & @MIN & ':' & @SEC & ';' & $TrapTitle
        FileWrite(@DesktopDir & '\testing.txt', $ActiveTime & $DeActiveTime & @CRLF)
        $TrapTitle = ''
        $Begin = 1
    EndIf
EndFunc

Func EXITTRACK()
    Exit
EndFunc

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

brilliant! :)

a thousand thanks!

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