Simple Productivity/Interruption Tracker

Post your working scripts, libraries and tools
User avatar
AlleyArtwork
Posts: 30
Joined: 09 Jun 2015, 21:08

Simple Productivity/Interruption Tracker

13 Sep 2018, 08:30

Hi All,
At work I felt the need to track how often I was being interrupted, and by who.
I started out with an extremely simple Hotkey to launch an inputbox to enter in a user. It would track my login, the user I entered, and time stamp it.

Eventually I wanted to track by which method I was being interrupted (walkups, phone, IM, slack, email, etc.) and also the duration, along with a description.
Then i noticed typos in people i was tracking, so I built in a quick AD lookup to make sure that usernames were consistent when being entered.
Eventually my whole team began to use this, and eventually still, other teams wanted to use it, so I added a way to create and switch between team databases where the information is tracked.

As with all things, i'm sure someone here can look at this and make it even better (especially the GUI which I am sure is laughable), but we've discovered that the data provided by tracking productivity interruptions has helped us identify offenders and schedule process training or other automations to help minimize or eliminate future interruptions from frequent offenders, or help with making cases about project interruptions due to other priorities (say a severity incident, or impromptu emergency from someone you probably shouldn't say no to).

Quick Start Guide:
on first use:
1) click New Database
2) Create a TXT file in a location of your choosing, then select that file
3) you can now save input with the GUI.

Other notes:
- The LogonID field is freeform, so if you wanted to track against something other than people, you may (like a cross-team project name for example)
- The Minutes/duration is also freeform if you want a custom value.
- The "report" opens data in CSV. If you are using excel you can then Pivot table & Graph out any datapoint you would like.
- If you only use this for yourself, you can create a local or home-drive file
- if you want this accessible for a team, you can create a file on a team's network drive
- if you want this available through out an entire department/business, you can create a file on a network share available by all teams

Code: Select all

;---------------------------------------------------------------
; Rudimentary Productivity Tracker.  Default: CTRL + WinKey + T to launch.
; While the LogonID field was built in mind with AD User IDs, it is Free Form so you can track against a person or a project if desired.
;---------------------------------------------------------------

;-----------------
; Set Hotkey to desired hotkey
^#t::

;-----------------
; Check if Window is already open and activate it.
IfWinExist, DisTrackter
{
	WinActivate, DisTrackter
}
else,
{
filereadline, timetrackerdb, %a_mydocuments%\distrackterdbpath.txt, 1

;-----------------
; GUI

; Button/Text for Instructions Connect Database and New Database
Gui, 99:Add, Text, x12 y3 w110 r1 ginstructions cblue, Click for instructions
Gui, 99:Add, text, x130 y3 w110 r1 gchangedb vchangedb cgray, [ Connect Database ]
Gui, 99:Add, Text, x250 y3 w110 r1 gnewdb vnewdb cgray, `+[ ] New database


Gui, 99:Add, GroupBox, x5 y22 h40 w335 cpurple center, Interruption Type
; Radio Button Group
Gui, 99:Add, Radio, x12 y36 w50 h20  vdisruptiongroup, Phone
Gui, 99:Add, Radio, x78 y36 w60 h20  , Walk-Up
Gui, 99:Add, Radio, x162 y36 w50 h20 , Email
Gui, 99:Add, Radio, x232 y36 w50 h20 , IM
Gui, 99:Add, Radio, x282 y36 w50 h20 , Slack

; Fields
Gui, 99:Add, Text, x5 y72 w25, LogonID:
Gui, 99:Add, Edit, x50 y70 w65  voffender, 
Gui, 99:Add, Text, x117 y72 w30, Desc:
Gui, 99:Add, Edit, x145 y70 w195  vdetails, 
Gui, 99:Add, Text, x117 y100 w30, Min:
Gui, 99:add,ComboBox, x145 y100 w50 vtimespent, 5||10|15|20|25|30|35|40|45|50|55|60

; Buttons
Gui, 99:Add, Button, x5 y100 w90 h20 gcheckname checkname, Check LogonID
Gui, 99:Add, Button, x5 y130 w65 h20 greport vreport, View Report
Gui, 99:Add, Button, x73 y130 h20 gdbopen vdbopent cgrey, Edit DB
Gui, 99:Add, Button, x252 y100 w70 h30 Default gsubmit vsubmit, Submit
Gui, 99:Add, Button, x252 y130 w90 h20 gcancel vcancel, Cancel/Close

; Status Bar
Gui, 99:Add, StatusBar,, DB:  %timetrackerdb%

Gui, 99:Show, w350 h195, DisTrackter 
return

;-----------------
; AD Query to check for names.
checkname:
gui, submit, nohide

if offender =
{
	MsgBox, You didn't enter any information!  Try Again!
	return
}
userdata = 
loopnumber = 
savefile = %a_mydocuments%\userdata.txt
FileDelete, %savefile%

;*******GetADObjectArray Function********;
GetADObjectArray(Query) {
objConnection := ComObjCreate("ADODB.Connection")
objConnection.Open("Provider=ADsDSOObject;")
 
objCommand := ComObjCreate("ADODB.Command")
objCommand.ActiveConnection := objConnection
objCommand.Properties("Page Size") := 100000
objCommand.CommandText := Query
objRecordSet := objCommand.Execute
 
;Create and populate a generic object with the data.
ADObjectArray := Object()
while objRecordSet.EOF = 0
{
    ADObject := Object()                
    for f in objRecordSet.fields
    {
                ADObject[f.name] := f.value
    }
                ADObjectArray[a_index] := ADObject
try {
objRecordSet.MoveNext
    }
    catch e {
        msgbox, No Dice.
        break
    }
}
objRecordSet.Close
objConnection.Close
query =
return ADObjectArray   
}   
;*******END - GetADObjectArray Function********;

;Build AD Query String   
UserQuery = SELECT pwdlastset, title, description, mail, sAMAccountName, employeeID, displayName, name, cn, sn, homeDirectory, telephoneNumber FROM 'LDAP://dc=rgl,dc=net' where objectCategory='user' AND samaccountname='*%offender%*'
 
Data := GetADObjectArray(UserQuery)
 
; Loop through Each record row returned from ADQuery
for k,v in Data
	{
		thename := v["displayName"]
		thefullname := v["name"]
		themail := v["mail"]
		thephone := v["telephoneNumber"]
		thepdrive := v["homeDirectory"]
		thepwdls := v["pwdlastset"]
		thetitle := v["title"]
		thedesc:= v["description"]
		thefirstname := v["cn"]
		thelastname := v["sn"]
		thesaman := v["sAMAccountName"]
		loopnumber := a_index
		userdata = %userdata%RESULT %loopnumber%: %thesaman% | %thefullname% | %thetitle%`n
		
		if thesaman =
			{
			MsgBox, The user doesn't appear to exist.
			return
			}	
	}


if userdata !=
	{
	userdata = ***Please Choose a UserID below ***`n`n`n%userdata%
	FileAppend, %userdata%, %savefile%
	sleep, 200
	run, %savefile%
	sleep, 200
	}
return


return

;-----------------
; Submits data to the DB using the field information
submit:
gui, submit, nohide

if timetrackerdb =
{
	MsgBox, Before you can save data you need to do one of the following:`n1) Change/Select an existing database, or... `n2) Create a new database TXT file.
return
}
	

if disruptiongroup = 0
{
	MsgBox, Choose a Radio button Option
	return
}

; Set Interrution category
if (disruptiongroup = 1){
disruptiongroup = Phone
}
if (disruptiongroup = 2){
disruptiongroup = Walk-Up
}
if (disruptiongroup = 3){
disruptiongroup = Email
}
if (disruptiongroup = 4){
disruptiongroup = IM
}
if (disruptiongroup = 5){
disruptiongroup = Slack
}

if details =
{
	MsgBox, You didn't enter any information!  Try Again!
	return
}


StringReplace, offender, offender, `|,, all
StringReplace, offender, offender, %A_Space%,, all
StringReplace, details, details, `,, `;, all	; Replace Comma with Semi-Colon as not to confuse CSV file created in report.
FileAppend, %A_MM%/%A_DD%/%A_YYYY%`,%A_Hour%:%A_Min%`,%a_username%`,%disruptiongroup%`,%offender%`,%timespent%`,%details%`n, %timetrackerdb%
GuiControl,, offender, 
GuiControl,, details, 
GuiControl,, Submit, Data Entered!
sleep, 1000
GuiControl,, Submit, Submit
return

;-----------------
; Change Database file
changedb:
gui, submit, nohide
MsgBox, Locate the Database file you wish to Connect to.
FileSelectFile, dbfilepath, ,,Choose your Team's Database file, *.txt
if errorlevel
	return
FileDelete, %a_mydocuments%\distrackterdbpath.txt
FileAppend, %dbfilepath%, %a_mydocuments%\distrackterdbpath.txt
filereadline, timetrackerdb, %a_mydocuments%\distrackterdbpath.txt, 1
SB_SetText("DB:  "  timetrackerdb)
return

;-----------------
; Create new DB
newdb:
gui, submit, nohide
MsgBox, Create a new TXT file for your database in a location of your choosing.
FileSelectFile, dbfilepath, ,,Choose your Team's Database file, *.txt
if errorlevel
	return
FileDelete, %a_mydocuments%\distrackterdbpath.txt
FileAppend, %dbfilepath%, %a_mydocuments%\distrackterdbpath.txt
FileAppend, DATE`,TIME`,LOGGED_BY`,TYPE`,WHO`,TimeSpent`,DETAILS`n, %dbfilepath%
filereadline, timetrackerdb, %a_mydocuments%\distrackterdbpath.txt, 1

SB_SetText("DB:  "  timetrackerdb)
return

;-----------------
; INSTRUCTIONS Message Box
instructions:
MsgBox, ** FIRST TIME USE:  Be sure to Connect Database to your team's Tracker Database.`nOptionally you can create a new database for your team or for private use.`n`n--Standard Use--`n1) Choose an interruption type.`n2) Enter user's Logon name.`n3) Enter a Description (include ticket if required)`n4) Choose a duration in munutes of the interruption (dropdown or enter custom).`n5) Click Submit!`n`n--Other Notes--`n- Your Login is automatically saved to the Database with each entry.`n- VIEW REPORT is read only. If you need to make a correction`, please use the Edit DB button.`n- You can use Check Username to confirm user's actual logon. This is to keep data entry consistent so that a user isn't being entered in multiple ways. (joe.smith, jsmith etc.)
return

;-----------------
; Runs a report on tracked data by reading the DB and putting it into a separate CSV file for viewing, pivoting, graphing in Excel
report:
IfWinExist, timetracker.csv
	{
	WinActivate, timetracker.csv
	}
else,
	{
	FileDelete, %A_MyDocuments%\timetracker.csv
	FileRead, timetrackerdata, %timetrackerdb%
	FileAppend, %timetrackerdata%, %A_MyDocuments%\timetracker.csv
	run, %A_MyDocuments%\timetracker.csv
	}	
return

;-----------------
; Opens the "Database" text file if corrections need to be made.
dbopen:
run, %timetrackerdb%
return

;-----------------
; Close GUI by cancel button
Cancel:
Gui Destroy
return

;-----------------
; Close GUI by Windows "X" button
99GuiClose:
Gui Destroy
return

return
}
return
loop {
MsgBox, Life is like an Infinite Message Box of chocolates.`nThere are %a_index% chocolates in this box.
}
burque505
Posts: 626
Joined: 22 Jan 2017, 19:37

Re: Simple Productivity/Interruption Tracker

14 Sep 2018, 14:25

@AlleyArt, that is very nice.
Regards,
burque505
User avatar
AlleyArtwork
Posts: 30
Joined: 09 Jun 2015, 21:08

Re: Simple Productivity/Interruption Tracker

16 Sep 2018, 16:17

Thanks guys, I hope you enjoy it or find the idea useful or can also put it to use as is.
If you can improve on it, or find a better way to do it please feel free to share.
I learned today, in the Discord chat, that i'm pretty much still quite the noob; and when helping someone, my 50 lines of code and multiple loops to accomplish something, was turned into a much cleaner 30 lines of code. Always learning and being humbled by people better than myself haha.
loop {
MsgBox, Life is like an Infinite Message Box of chocolates.`nThere are %a_index% chocolates in this box.
}

Return to “Scripts and Functions”

Who is online

Users browsing this forum: au6 and 49 guests