OnExit,Exit #SingleInstance force #Persistent Gosub, ReadIni Gosub, TrayMenu Gosub, Idletimedefine Gosub, StartTimer Return ReadIni: ;;; ;Iniread IniRead, Custom1, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 1, Out to Lunch ;Read values from ini file IniRead, Custom2, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 2, In a meeting IniRead, Custom3, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 3, Taking a Phone Call IniRead, Custom4, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 4, Site Visit IniRead, Custom5, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 5, Undefined IniRead, Custom6, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 6, Undefined IniRead, Custom7, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 7, Undefined IniRead, Custom8, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 8, Undefined IniRead, idletime, %A_Scriptdir%\TitleLog Prefs.ini, Idletime, 1, 15 IniRead, donotlog, %A_Scriptdir%\TitleLog Prefs.ini, Donotlog, 1, If donotlog= { donotlog=Set this to text from a changing title bar } Return ;; Traymenu: ;;; ;menu tray with custom labels Menu, tray, add, ABOUT..., ABOUT ;create a tray Menu Menu, tray, add, Preferences...,PrefsGui Menu, tray, add, Menu, tray, add, Add Comment to Log...,Comment Menu, tray, add, Menu, tray, add, Show Summary Log..., Dlog Menu, tray, add, Show Details Log..., TLog Menu, Tray, add, If (Custom1<>"Undefined" and Custom1<>"") ;if underfined or empty, dont show in Tray Menu Menu, tray, add, %Custom1%, M1 If (Custom2<>"Undefined" and Custom2<>"") Menu, tray, add, %Custom2%, M2 If (Custom3<>"Undefined" and Custom3<>"") Menu, tray, add, %Custom3%, M3 If (Custom4<>"Undefined" and Custom4<>"") Menu, tray, add, %Custom4%, M4 If (Custom5<>"Undefined" and Custom5<>"") Menu, tray, add, %Custom5%, M5 If (Custom6<>"Undefined" and Custom6<>"") Menu, tray, add, %Custom6%, M6 If (Custom7<>"Undefined" and Custom7<>"") Menu, tray, add, %Custom5%, M7 If (Custom8<>"Undefined" and Custom8<>"") Menu, tray, add, %Custom6%, M8 Menu, tray, add, Menu, tray, add, Explore Log Folder...,mExplore Menu, tray, add, Menu, tray, add, exit, TerminateLog Menu, tray, tip, %A_Scriptname% `nA Personal Logfile Menu, tray, NoStandard Return ;; Idletimedefine: ;;; ;idle time in secs idletimesecs:=(idletime * 60000) ;convert milliSeconds to Seconds FileCreateDir, %A_Scriptdir%\TitleLog ;if not created, create a log folder Return ;; DetailGui: ;;; ;Detail View Gui, Search GUI Gui , 1:add, text , , Choose a date to view from Gui , 1:add, DateTime , w100 x+10 vMyStartDate gLfolder, Gui , 1:add, text , x+50, to Gui , 1:add, DateTime , w100 x+10 vMyEndDate gLfolder, Gui , 1:add, GroupBox , xs w780 h60, Filters Gui , 1:add, text , x145 y50 ,>Seconds Gui , 1:add, text , x+20 y50 ,Application Name Gui , 1:add, text , x+50 y50 ,Include in Window Title Gui , 1:add, text , x+140 y50 ,Exclude in Window Title Gui , 1:add, edit , x145 y63 w50 vValueSeconds gSearchAppList, Gui , 1:add, edit , x+10 y63 w120 vValueprogram gSearchAppList, Gui , 1:add, edit , x+10 y63 w240 vValueinclude gSearchAppList , Gui , 1:add, edit , x+10 y63 w130 vValueexclude gSearchAppList, Gui , 1:add, text , xs , Sort All columns by Clicking on the header bar Gui , 1:add, ListView , xm r35 w780 vMyListView,YYYYMMDD|Time|Elapsed|Application|Window Title Gui , 1:add, Button , x10 w150 gRefreshShowAppList,&Refesh && Reset List Gui , 1:add, Button , x+5 w150 gSavecurrentAppList,&Save current List Gui , 1:add, Button , x+5 w150 gmexplore,&Explore log folder Gui , 1:add, Button , x+5 w150 gDlog,Summary &View Gui , 1:font, Bold Gui , 1:add, Button ,x+10 w150 gmClose, &Close Gui , 1:add, StatusBar ,, Return ;; PrefsGui: ;;; ;PrefsGui Gui SetTimer, logchanges, OFF ;stop the timer whilst showing PrefsGui Gui Gui, 2:Destroy Gui, 2:+AlwaysOnTop Gui, 2:Font,Bold Gui, 2:Add, GroupBox, w300 h50,Preferences Gui, 2:font Gui, 2:add, text, xp+10 yp+25 ,Time before logging as idle(mins) Gui, 2:add, edit ,x+30 w40 vIdletime, Gui, 2:add, UpDown, Range 1-60,%idletime% Gui, 2:Font,Bold Gui, 2:Add, GroupBox,xs w300 h80 Section,Do NOT Log Gui, 2:Font Gui, 2:Add, text ,xp+10 yp+20 ,Windows titles that contain Gui, 2:Add, edit ,xp yp+20 w270 vdonotlog, Gui, 2:Font,Bold Gui, 2:Add, GroupBox,xs w300 h230,Preset Messages for Tray Menu Gui, 2:Font Gui, 2:add, text ,xp+10 yp+25,Window1 Gui, 2:add, text ,yp+25 ,Window2 Gui, 2:add, text ,yp+25 ,Window3 Gui, 2:add, text ,yp+25 ,Window4 Gui, 2:Add, text ,yp+25 ,Window5 Gui, 2:Add, text ,yp+25 ,Window6 Gui, 2:Add, text ,yp+25 ,Window7 Gui, 2:Add, text ,yp+25 ,Window8 Gui, 2:Add, Edit ,xp+60 yp-180 w220 vCustom1,%Custom1% Gui, 2:Add, Edit ,yp+25 w220 vCustom2,%Custom2% Gui, 2:Add, Edit ,yp+25 w220 vCustom3,%Custom3% Gui, 2:Add, Edit ,yp+25 w220 vCustom4,%Custom4% Gui, 2:Add, Edit ,yp+25 w220 vCustom5,%Custom5% Gui, 2:Add, Edit ,yp+25 w220 vCustom6,%Custom6% Gui, 2:Add, Edit ,yp+25 w220 vCustom7,%Custom7% Gui, 2:Add, Edit ,yp+25 w220 vCustom8,%Custom8% Gui, 2:Font,Bold Gui, 2:Add, Button, xs y+25 x10 w300 Section Default gSave,&Save Gui, 2:Show,,%A_Scriptname% Preferences GuiControl,2:, donotlog, %donotlog% ;add text to Gui edit from saved ini file Return ;; SummaryGui: ;;; ;Show AppList, Summary Gui Gui, 4: Destroy Gui, 4: add , text , , Choose start date to view Gui, 4: add , DateTime, x+10 vSummaryDateTimeStart gsummarydatenew, Gui, 4: add , text , xs , Choose end date to view Gui, 4: add , DateTime, x+10 vSummaryDateTimeEnd gsummarydatenew, Gui, 4: add , text ,xs+15 , Application Name Gui, 4: add , text ,x+210 , Titles of Application Gui, 4: Add , TreeView , h500 w280 xs gMyTree ;treelist of used applications Gui, 4: Add , ListView , h500 w580 x+10 vtitleList Sort, hhmmss|Window Title Name Gui, 4: Font,Bold Gui, 4: add , Button, xs w380 gRefreshShowAppList, &Open Detail View Gui, 4: add , Button, x+50 w380 gmClose, &Close Gui, 4: add , StatusBar ,, Return ;; StartTimer: ;;; ;check & log changes every 1 sec SetTimer, logchanges, 1000 Return ;; Logchanges: ;;; ;if change write line to file WinGetActiveTitle, WindowTitleCurrent ;retrieve the current title WindowTitleCurrent=%WindowTitleCurrent% ;strip any whiteSpace IfInString, WindowTitleCurrent, %donotlog% ;if donotlog is in the title then Return { Return ;this will NOT stop the Counter } If WindowTitleCurrent<>%WindowTitlePrevious% ;compare with the last window x Seconds ago if different { ;move this section as a gosub, add gosub to idlelog to capture beginning current=%A_Now% ;mark the time of change EnvSub,current,%PreviousWindowChangeTime%,Seconds ;how long since the last window change result:= FormatSeconds(current) ;format this in Seconds WinGet, WindowProcessName, ProcessName, %WindowTitleCurrent% ;retrieve the current windows application name ;tooltip, %A_YYYY%%A_MM%%A_DD%`,%A_Hour%%A_Min%`,"%WindowProcessNamePrevious%"`,"%WindowTitlePrevious%"`,"%current%"`,"%result%"`n FileAppend, `"%A_YYYY%%A_MM%%A_DD%`"`,`"%A_Hour%%A_Min%`"`,"%WindowProcessNamePrevious%"`,"%WindowTitlePrevious%"`,"%current%"`,"%result%"`n, %A_Scriptdir%\TitleLog\%A_YYYY%%A_MM%%A_DD%.csv PreviousWindowChangeTime=%A_Now% ;set the last change time WindowTitlePrevious=%WindowTitleCurrent% ;set the current window to the old for next loop WindowProcessNamePrevious=%WindowProcessName% } IfGreater, A_TimeIdle, %idletimesecs% ;Check if idle time trigerred { Gosub,IdleLog ;Gosub to idlelog } Return ;; IdleLog: ;;; ;Idle Gui SetTimer, logchanges, OFF idlestarttime=%A_Now% ;log the time Right now its:=(0-idletimesecs/1000) ;less the idle trigger time in Seconds EnvAdd,idlestarttime,%its%,Seconds ;calculate the idle start time FormatTime, Outputidlestart, %idlestarttime%,"yyyyMMdd","HHmm" FileAppend, %idlestarttime%`,"%WindowProcessNamePrevious%"`,"%WindowTitlePrevious%"`,"%current%"`,"%result%"`n, %A_Scriptdir% Gui,6:-SysMenu +AlwaysOnTop Gui,6:add, text,,This message box generated by TitleLog idle alarm`, triggered after "%idletime%" minute.`nEnter a brief desription of what you have been doing whilst desktop has been idle. Gui,6:add,edit,w600 vSDedit, Gui,6:add,text,xs,Quick Text Buttons Gui,6:add,Button,xs+5 w140 gCust1 , %Custom1% Gui,6:add,Button,x+10 w140 gCust2 , %Custom2% Gui,6:add,Button,x+10 w140 gCust3 , %Custom3% Gui,6:add,Button,x+10 w140 gCust4 , %Custom4% Gui,6:Font,Bold Gui,6:add,Button, xs y+20 w600 gIdleText Default, &Save Text to Log Gui,6:Font Gui,6:add, StatusBar,,%idletime% Gui,6:show,,The Desktop has triggered the idle threshold of %idletime% Minutes. SetTimer, 1minuteCounter, 1000 ;start Counting the idle time display in the StatusBar of Gui6 Return ;; IdleText: ;;; ;save idletext submit GUI and write to file Gui, 6:Submit Gui, 6:Destroy current=%A_Now% ;get current time EnvSub,current,%idlestarttime%,Seconds ;current time - last logged time = in Seconds result:= FormatSeconds(current) ;Goto function to format in hh:mm:ss FileAppend, `"%A_YYYY%%A_MM%%A_DD%`"`,`"%A_Hour%%A_Min%`"`,"Idle Text"`,"%SDedit%"`,"%current%"`,"%result%"`n , %A_Scriptdir%\TitleLog\%A_YYYY%%A_MM%%A_DD%.csv previous=%A_Now% SetTimer, logchanges, ON Return ;; 1minutecounter: ;;; ;counter for idlelog gui currentm=%A_Now% ;get current time EnvSub,currentm,%idlestarttime%,Seconds ;current time - last logged time = in Seconds idleresult:= FormatSeconds(currentm) ;Goto function to format in hh:mm:ss Gui,6:Default SB_SetParts(350, 250) SB_SetText("This PC has been idle for " . idleresult . " hhmmss. " ,1 ) SB_SetText("Reminder, not logging titles with " . donotlog . ,2 ) GuiControl,2:, donotlog, %donotlog% Return ;; Cust1: ;;; ;Custom message control for idle alarm Gui, 6:Submit, NoHide GuiControl,6:,SDedit,%SDedit% %custom1% Return Cust2: Gui, 6:Submit, NoHide GuiControl,,SDedit,%SDedit% %custom2% Return Cust3: Gui, 6:Submit, NoHide GuiControl,,SDedit,%SDedit% %custom3% Return Cust4: Gui, 6:Submit, NoHide GuiControl,,SDedit,%SDedit% %custom4% Return ;; Comment: ;;; ;Comment Gui triggered from tray menu SetTimer, logchanges, OFF Gui, 7:-SysMenu +AlwaysOnTop Gui, 7:add, Text,,Add a Comment to the Log Gui, 7:add, edit, w600 vcmnts, Gui, 7:Add, GroupBox, w600 h60,Quick Text Buttons Gui, 7:add, Button,xp+5 yp+25 w140 gCustComment1 , %Custom1% Gui, 7:add, Button,x+10 w140 gCustComment2 , %Custom2% Gui, 7:add, Button,x+10 w140 gCustComment3 , %Custom3% Gui, 7:add, Button,x+10 w140 gCustComment4 , %Custom4% Gui, 7:Font,Bold Gui, 7:add, Button,xs w600 gsavecomment Default, &Save comments Gui, 7:show,,Add a Comment Return ;; CustComment1: ;;; ;Custom message control for idle alarm Gui, 7:Submit, NoHide GuiControl,7:,cmnts,%cmnts% %custom1% Return CustComment2: Gui, 7:Submit, NoHide GuiControl,,cmnts,%cmnts% %custom2% Return CustComment3: Gui, 7:Submit, NoHide GuiControl,,cmnts,%cmnts% %custom3% Return CustComment4: Gui, 7:Submit, NoHide GuiControl,,cmnts,%cmnts% %custom4% Return ;; savecomment: ;;; ;save comment Gui, 7:Submit ;add a comment to the log Gui, 7:Destroy FileAppend, `"%A_YYYY%%A_MM%%A_DD%`"`,`"%A_Hour%%A_Min%`"`,"Custom Comment"`,"%cmnts%"`,""`,""`n, %A_Scriptdir%\TitleLog\%A_YYYY%%A_MM%%A_DD%.csv SetTimer, logchanges, ON Return ;; PresetMessages: ;;; ;M1 to M8 display preset GUI triiger from tray M1: Gui,3: Destroy Gui,3: +AlwaysOnTop Gui,3: Font,s14 Gui,3: add, text,w300 h30 Center,%Custom1% Gui,3: add, Button,ym w60 Default gmClose,Close Gui,3: show,,%Custom1% SetTimer, logchanges, off Return M2: Gui, Destroy Gui, +AlwaysOnTop Gui, Font,s14 Gui, add, text,w300 h30 Center,%Custom2% Gui, add, Button,ym w60 Default gmClose,Close Gui, show,,%Custom2% SetTimer, logchanges, off Return M3: Gui, Destroy Gui, +AlwaysOnTop Gui, Font,s14 Gui, add, text,w300 h30 Center,%Custom3% Gui, add, Button,ym w60 Default gmClose,Close Gui, show,,%Custom3% SetTimer, logchanges, off Return M4: Gui, Destroy Gui, +AlwaysOnTop Gui, Font,s14 Gui, add, text,w300 h30 Center,%Custom4% Gui, add, Button,ym w60 Default gmClose,Close Gui, show,,%Custom4% SetTimer, logchanges, off Return M5: Gui, Destroy Gui, +AlwaysOnTop Gui, Font,s14 Gui, add, text,w300 h30 Center,%Custom5% Gui, add, Button,ym w60 Default gmClose,Close Gui, show,,%Custom5% SetTimer, logchanges, off Return M6: Gui, Destroy Gui, +AlwaysOnTop Gui, Font,s14 Gui, add, text,w300 h30 Center,%Custom6% Gui, add, Button,ym w60 Default gmClose,Close Gui, show,,%Custom6% SetTimer, logchanges, off Return M7: Gui, Destroy Gui, +AlwaysOnTop Gui, Font,s14 Gui, add, text,w300 h30 Center,%Custom7% Gui, add, Button,ym w60 Default gmClose,Close Gui, show,,%Custom7% SetTimer, logchanges, off Return M8: Gui, Destroy Gui, +AlwaysOnTop Gui, Font,s14 Gui, add, text,w300 h30 Center,%Custom8% Gui, add, Button,ym w60 Default gmClose,Close Gui, show,,%Custom8% SetTimer, logchanges, off Return ;; mclose: ;;; ;Close exit escape guiescape: guiclose: GuiControl,,valueinclude, ;reset valueinclude to blank ? LV_Delete() ;Destroys the AppList in the ListView Gui,Destroy SetTimer, logchanges, ON ;turn the timer back ON Return ;; Save: ;;; ;save and submit to ini from PrefsGui GUI:2 Gui, 2:Submit IniWrite, %Custom1%, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 1 IniWrite, %Custom2%, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 2 IniWrite, %Custom3%, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 3 IniWrite, %Custom4%, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 4 IniWrite, %Custom5%, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 5 IniWrite, %Custom6%, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 6 IniWrite, %Custom5%, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 7 IniWrite, %Custom6%, %A_Scriptdir%\TitleLog Prefs.ini, Custom, 8 IniWrite, %Idletime%, %A_Scriptdir%\TitleLog Prefs.ini, Idletime, 1 IniWrite, %donotlog%, %A_Scriptdir%\TitleLog Prefs.ini, Donotlog, 1 Gui, 2:Destroy current=%A_Now% EnvSub,current,%previous%,Seconds result:= FormatSeconds(current) FileAppend, `"%A_YYYY%%A_MM%%A_DD%`"`,`"%A_Hour%%A_Min%`"`,"%A_Scriptname%"`,"TitleLog preferences saved by user"`,"%current%"`,"%result%"`n, %A_Scriptdir%\TitleLog\%A_YYYY%%A_MM%%A_DD%.csv Reload ; todo , need to get rid of this , or add Closeing Lines Return ;; DLog: ;;; ; Gui,4: Destroy Gosub, SummaryGui ;something about initial loading, ????? Gosub , Summary Return ;; summarydatenew: ;;; ; Gui,4: Submit, NoHide ;; ;get values in Gui but dont Destroy Gui ;;todo create error chack that end is equal of after begin Summary: ;;; ;Summary Loop, %Count% ;reset the Progtime each time date changed { Progtime%A_Index%= } Gui,4: Submit, NoHide ;get values in Gui but dont Destroy Gui StringTrimRight,SummaryDateTimeStart,SummaryDateTimeStart,6 StringTrimRight,SummaryDateTimeEnd,SummaryDateTimeEnd,6 LV_Delete() ;Destroys the AppList in the ListView TV_Delete() programAppList= AppList= TitleList= AccumTime= GuiControl, -Redraw, SummaryView ; Gui, 4:Default Gui,4:show,,Summary view of Applications filedate=%SummaryDateTimeStart% Loop { If (filedate > SummaryDateTimeEnd) ;if the file date is greater the the enddate { Break ;Exit loop } Loop, Read, %A_Scriptdir%\Titlelog\%filedate%.csv ;Read the days log one line at a time { Loop, Parse, A_LoopReadLine, csv ;Parse the line into seperate variables { A%A_Index%=%A_Loopfield% ;give each field a separate variables name letter 'A' } If a3= ;if no application logged, skip to next line in text file { Continue } If a3 not in %AppList% { AppList=%AppList%,%A3% ;add new Application to AppList variable AccumTimeAppName=%a3% Count +=1 Gosub , AcculalateTime Accresult:= FormatSeconds(AccumTime) AppAndTime= %Accresult% - %a3% a3:=TV_Add(AppAndTime) ;hhmmss " " ;add application name to TreeView } } filedate:=filedate+1 ;increment filedate Count 1 day } Count -=1 ;no more apps, so decrease Count by 1 TV_Modify(0, "Sort"). ;SB_SetText("There are " . Count . " different applications AppListed. " ,1 ) Return ;; AcculalateTime: ;;; AccumTime=0 filedate2=%SummaryDateTimeStart% Loop { If (filedate2 > SummaryDateTimeEnd) ;if the file date is greater the the enddate { Return ;Exit loop } Loop, Read, %A_Scriptdir%\Titlelog\%filedate2%.csv ;Read the days log one line at a time { Loop, Parse, A_LoopReadLine, csv ;Parse the line into seperate variables { b%A_Index%=%A_Loopfield% ;give each field a separate variables name letter 'A' } If (b3=AccumTimeAppName) { AccumTime:=AccumTime+b5 } } filedate2:=filedate2+1 ;increment filedate Count 1 day } Return ;; MyTree: ;;; ;This subroutine handles user actions (such as clicking). If A_GuiEvent <> S ; i.e. an event other than "select new tree item". Return ; Do nothing. TV_GetText(SelectedItemText, A_EventInfo) StringTrimLeft , SelectedItemText , SelectedItemText ,11 ParentID := A_EventInfo Loop ; Build the full path to the selected folder. { ParentID := TV_GetParent(ParentID) If not ParentID ; No more ancestors. Break TV_GetText(ParentText, ParentID) } ; Put the files into the ListView: LV_Delete() ; Clear all rows. GuiControl, -Redraw, MyListView ; Improve performance by disabling Redrawing during load. filedate3=%SummaryDateTimeStart% TitleList= Acctitletime= Loop { If (filedate3 > SummaryDateTimeEnd) ;if the file date is greater the the enddate { Break ;Exit loop } Loop, Read, %A_Scriptdir%\Titlelog\%filedate3%.csv ;Read the days log one line at a time { Loop, Parse, A_LoopReadLine, csv ;Parse the line into seperate variables { A%A_Index%=%A_Loopfield% ;give each field a separate variables name letter 'A' } If a3=%SelectedItemText% { If a4 not in %TitleList% { AccumTime=0 filedate4=%SummaryDateTimeStart% Loop { If (filedate4 > SummaryDateTimeEnd) ;if the file date is greater the the enddate { Break ;Exit loop } Loop, Read, %A_Scriptdir%\Titlelog\%filedate4%.csv ;Read the days log one line at a time { Loop, Parse, A_LoopReadLine, csv ;Parse the line into seperate variables { b%A_Index%=%A_Loopfield% ;give each field a separate variables name letter 'A' } If (a3=b3) { If (a4=b4) { AccumTime:=AccumTime+b5 } } } filedate4:=filedate4+1 ;increment filedate Count 1 day } titleresult:= FormatSeconds(AccumTime) LV_Add("", titleresult, A4) Acctitletime:=Acctitletime+a5 TitleList=%TitleList%,%A4% ;add new title to TitleList } } } FileCount += 1 filedate3:=filedate3+1 ;increment filedate Count 1 day } GuiControl, +Redraw, MyListView LV_ModifyCol() LV_ModifyCol(1,70) Return ;; TLog: ;;; ;TLog from tray menu , destroy Detail GUI and reshow Gui,1: Destroy Gosub, DetailGui Gosub, SearchAppList Return ;; RefreshShowAppList: ;;; ;Refresh , but I doubt this works Gui,1: Destroy Gosub, DetailGui ;; ;rebuild the Gui with all new Defaults Lfolder: ;;; ;L Folder load a different file in Search GUI Gui, Submit, NoHide ;; ;get values in Gui but dont Destroy Gui SearchAppList: ;;; ;Search AppList and Show Detail DetailGui. Gui, Submit, NoHide ;get values in Gui but dont Destroy Gui PreSearchValueexclude=%Valueexclude% PreSearchValueinclude=%Valueinclude% PreSearchValueSeconds=%ValueSeconds% PreSearchValueprogram=%Valueprogram% Gui,1:Default StringTrimRight,MyStartDate,MyStartDate,6 StringTrimRight,MyEndDate,MyEndDate,6 LV_Delete() ;Destroys the AppList in the ListView programAppList= filteredAppList= filteredtime=0 GuiControl, -Redraw, MyListView ; Loop { If (MyStartDate > MyEndDate) ;if the file date is greater the the enddate { Break ;Exit loop } Loop, Read,%A_Scriptdir%\Titlelog\%MyStartDate%.csv { Loop, Parse, A_LoopReadLine, csv { A%A_Index%=%A_Loopfield% ;Break the line into separate variables } If a3= ;if no title logged, skip to next line in text file { Continue } IfGreater A5,%valueSeconds% ;if Seconds greater then prefs { Searchstring1= ;reset variables Searchstring2= Searchstring3= Searchstring4= Loop, Parse, Valueinclude, %A_Space%, ;load different variables for the search field { Searchstring%A_Index%=%A_LoopField% } IfInString, A4,%Searchstring1% ;search that line for a match IfInString, A4,%Searchstring2% ;search that line for a match IfInString, A4,%Searchstring3% ;search that line for a match IfInString, A4,%Searchstring4% ;search that line for a match IfInString, A3,%Valueprogram% { If Valueexclude= { LV_Add("",A1,A2,A6,A3,A4) filteredAppList=%filteredAppList%`n%A_loopReadline% filteredtime:=filteredtime+A5 } IfNotInString, A4, %Valueexclude% { LV_Add("",A1,A2,A6,A3,A4) filteredAppList=%filteredAppList%`n%A_loopReadline% filteredtime:=filteredtime+A5 ;trying to get a total value } } } } MyStartDate:=MyStartDate+1 ;increment MyStartDate Count 1 day } Gui, Submit, NoHide ;re-get values and Check that no further changes If Valueinclude = %PreSearchValueinclude% { If Valueexclude = %PreSearchValueexclude% { If ValueSeconds = %PreSearchValueSeconds% { If Valueprogram = %PreSearchValueprogram% { StatusBartime:= FormatSeconds(filteredTime) ;format this in Seconds GuiControl, +Redraw, MyListView LV_ModifyCol() LV_ModifyCol(1,80) LV_ModifyCol(2,50) LV_ModifyCol(3,60) LV_ModifyCol(4,130) CountLines:=LV_GetCount() SB_SetParts(150, 220) SB_SetText("There are " . CountLines . " records. " ,1 ) SB_SetText("Total time is " StatusBartime . " hh:mm:ss ",2) FormatTime, viewdate, %MyStartDate%, dddd, dd MMM yyyy ;SB_SetText("Date currently viewing " viewdate ,3) Gui, 1:Show, ,Title Log view - the file date is %A1% Return } } } } Else { Goto, SearchAppList ;recompile search results if search string different } Return ;; SavecurrentAppList: ;;; ;Save Current AppList FileSelectFile, OutputVar , s10, %A_Scriptdir%\TitleLog\%A_YYYY%%A_MM%%A_DD%_filtered.csv ,,*.csv; *.txt FileAppend, %filteredAppList% , %OutputVar% Return ;; mExplore: ;;; ;open in notepad Run, C:\Windows\explorer.exe "%A_Scriptdir%\Titlelog\" Return ;; FormatSeconds(NumberOfSeconds) ;;; ;Formats seconds function { time = 19990101 time += %NumberOfSeconds%, Seconds FormatTime, mmss, %time% T8, hh:mm:ss Return mmss ;NumberOfSeconds ;mmss ; //3600 ":" mmss } ;; ABOUT: ;;; ;About GUI Gui,9:Destroy Gui,9:Font,Bold Gui,9:Add,Text,x+10 yp+10,%A_Scriptname% , by Brett Gui,9:Font Gui,9:Add,Text,xm+10,'%A_Scriptname%' simply logs the title of the active window. Gui,9:Add,Text,xs,A folder called TitleLog is created as a subdirectory of the script. Gui,9:Add,Text,xs,Each day a new file is created with a datestamp name. Gui,9:Add,Text,xs,Each active window is logged to the text file in CSV format. Gui,9:Add,Text,xs,Right Click on the taskbar Icon to set preferences Gui,9:Add,Text,xs,Right Click on the taskbar Icon to activate 6 custom windows, Gui,9:Add,Text,xs,ie, Out to Lunch, In a Meeting, Gui,9:Add,Text,xs,Set the Idle log time in preferences Gui,9:Add,Text,y+0,`t Gui,9:Font,Bold Gui,9:Add,Text,xm+10 yp+10,DonationCoder Gui,9:Font Gui,9:Add,Text,xm+10,Please support the DonationCoder community Gui,9:Font,CBlue underline Gui,9:Add,Text,xm+10 GDONATIONCODER,www.DonationCoder.com Gui,9:Font Gui,9:Add,Text,y+0,`t Gui,9:Font,Bold Gui,9:Add,Text,xm+10 yp+10,AutoHotkey Gui,9:Font Gui,9:Add,Text,xm+10,This Application was made using AutoHotkey Gui,9:Font,CBlue underline Gui,9:Add,Text,xm+10 GAUTOHOTKEY,www.AUTOHOTKEY.com Gui,9:Font Gui,9:Add,Text,y+0,`t Gui,9:Add,Button,GABOUTOK Default w75,&OK Gui,9:Show,,About %A_Scriptname% Return ABOUTOK: Gui, 9:Destroy Return DONATIONCODER: Run,http://www.donationcoder.com,,UseErrorLevel Return AUTOHOTKEY: Run,http://www.autoHotkey.com,,UseErrorLevel Return ;; TerminateLog: ;;; ;terminate and close log file current=%A_Now% EnvSub,current,%previous%,Seconds result:= FormatSeconds(current) line2write="%A_YYYY%%A_MM%%A_DD%"`,"%A_Hour%%A_Min%"`,"%WindowProcessNamePrevious%"`,"%WindowTitlePrevious%"`,"%current%"`,"%result%"`n FileAppend, %line2write%, %A_Scriptdir%\TitleLog\%A_YYYY%%A_MM%%A_DD%.csv FileAppend, "%A_YYYY%%A_MM%%A_DD%"`,"%A_Hour%%A_Min%"`,"%A_Scriptname%"`,"TitleLog.exe Exited by User"`,"0"`,"0:00:00"`n, %A_Scriptdir%\TitleLog\%A_YYYY%%A_MM%%A_DD%.csv exit: ExitApp ;; ;;;todo resize window ;;;todo fix filterdialog to check after execute . Working 25-01-08 ;;;todo create a end of day record? ;;;todo add a progress bar