I would like to share a simple TimeClock script I wrote, that logs the start time and relevant information to aid in billing. The time keeping applications I found for sale on the internet did not provide for detailed time keeping and reporting. With the detail in the timeclock file, I can analyze and report time spent on projects, and provide detailed billings to clients. When working as a consultant, I found the detailed time billing allays any fears about padding time and provides accountability.
I would like to encourage a collaboration to enhance this script as well. One enhancement that I have not yet been able to manage is the ability to add previous project information as a drop down or pop up to aid the user in entering the project to be billed and make it easier to switch back and forth between existing projects.
I am relatively new to AutoHotKey, but already a great proponent. Feel free to suggest better ways to accomplish what I have written, as I have found this forum to be full of friendly and helpful people that try to encourage new users.
I keep my scripts in a folder C:\Scripts, and this script uses a TimeClock sub-folder and a few .ini files to store important information. The start time is stored in a file, so timekeeping can be resumed after a crash or reboot.
I tried to do a thorough search or this forum for timekeeping scripts, and hope this script offering something worthwhile to other users. I have already shared what I have with other users in my trade, and they have found it worth using for their businesses as well.
Thanks to Garry for the running time indicator script that I have used to provide the active indicator at the top of the screen. I hope I have provided the proper acknowledgment in my header comments for the use of his code. Any tips on this sort of etiquette are welcome.
Thanks in advance for your contributions to enhancements, Kirk
Code:
;
; AutoHotkey Version: 1.0.46.09
; Language: English
; Platform: Windows XP
; Author: WoodWorks <script@kelseywoodworks.com>
; No warrantees are expressed or implied as to the reliability or suitability of this script. Use at your own Risk!
;
;
; TimeClock v1.0 (3/18/2007):
; Simple Time logging with Customer and Project Information
; Screen Top Clock courtesy of AutoHotKey posting by garry http://www.autohotkey.com/forum/topic12125.html
;
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance force ; Force only one running copy of Script
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
CoordMode, Mouse, Relative
SetTitleMatchMode, 2 ; Match partial title only to allow for different versions of Alibre Design
; SetControlDelay, 30 ; Give the Controls a little more time to take effect for greater reliability (20=Default)
IniRead, Employee, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, Employee, %A_Space%
IniRead, Customer, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, Customer, %A_Space%
IniRead, Project, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, Project, %A_Space%
IniRead, Description, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, Description, %A_Space%
IniRead, StartTime, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, StartTime, %A_Space%
TimeClockEntry:
IfEqual, StartTime ; If NO Start Time, then default to Starting Time Clock
{
Gui, Destroy
Gui, Add, Edit, vEmployee x26 y30 w100 h20 , %Employee%
Gui, Add, Edit, vCustomer x26 y80 w120 h20 , %Customer%
Gui, Add, Edit, vProject x156 y80 w260 h20 , %Project%
Gui, Add, Edit, vDescription x26 y130 w390 h20 , %Description%
Gui, Add, Button, default x156 y20 w120 h30 , &START
Gui, Add, Button, x296 y20 w120 h30 , STO&P
Gui, Add, Text, x26 y10 w100 h20 , Employee:
Gui, Add, Text, x26 y60 w120 h20 , Customer:
Gui, Add, Text, x156 y60 w260 h20 , Project:
Gui, Add, Text, x26 y110 w390 h20 +Left, Description:
Gui, Show, x555 y449 h163 w447, TimeClock
Return
}
Else ; Since there is a Start Time, Default to Stopping Time Clock
{
Gui, Destroy
Gui, Add, Edit, vEmployee x26 y30 w100 h20 , %Employee%
Gui, Add, Edit, vCustomer x26 y80 w120 h20 , %Customer%
Gui, Add, Edit, vProject x156 y80 w260 h20 , %Project%
Gui, Add, Edit, vDescription x26 y130 w390 h20 , %Description%
Gui, Add, Button, x156 y20 w120 h30 , &START
Gui, Add, Button, default x296 y20 w120 h30 , STO&P
Gui, Add, Text, x26 y10 w100 h20 , Employee:
Gui, Add, Text, x26 y60 w120 h20 , Customer:
Gui, Add, Text, x156 y60 w260 h20 , Project:
Gui, Add, Text, x26 y110 w390 h20 +Left, Description:
FormatTime, StartDisplay, %StartTime%, yyyy-MM-dd HH:mm:ss
Gui, Add, Text, cFF0000 x145 y0 w280 h20 +Center, TimeClock Started at: %StartDisplay%
Gui, Show, x555 y449 h163 w447, TimeClock
Return
}
GuiEscape:
GuiClose:
ExitApp
ButtonSTOP:
Gui, Submit
IfEqual, StartTime ; If StartTime is blank (Not Initialized)
{
MsgBox, 52, TimeClock, No Start Time! Use Previous Stop Time?
IfMsgBox, No
ExitApp
Else
IniRead, StartTime, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, StopTime, %A_Space%
}
StringUpper, Employee, Employee, T
StringUpper, Customer, Customer
;StringUpper, Project, Project, T
;StringUpper, Description, Description, T
IniRead, CustomerName, C:\Scripts\TimeClock\Customers.ini, Customers, %Customer%
IfEqual, CustomerName, ERROR ; Customer Name NOT Found
{
InputBox, CustomerName, Customer Entry, Customer Entry %Customer% NOT Found! Enter Customer Name or Cancel., ,500
IfEqual, ErrorLevel, 0 ; OK was pressed
{
IniWrite, %CustomerName%, C:\Scripts\TimeClock\Customers.ini, Customers, %Customer%
IniRead, ProjectRate, C:\Scripts\TimeClock\Projects.ini, %CustomerName%, %Project%
IfEqual, ProjectRate, ERROR ; Project Rate Entry NOT Found
{
InputBox, ProjectRate, Project Entry, Project Entry %Project% NOT Found for %Customer% ! Enter Project RATE($) or Cancel., ,550
IfEqual, ErrorLevel, 0 ; OK was pressed
{
IniWrite, %ProjectRate%, C:\Scripts\TimeClock\Projects.ini, %CustomerName%, %Project%
}
Else
Goto TimeClockEntry
}
}
Else
{
Goto TimeClockEntry
}
}
Else ; Customer Entry Found
{
IniRead, ProjectRate, C:\Scripts\TimeClock\Projects.ini, %CustomerName%, %Project%
IfEqual, ProjectRate, ERROR ; Project Rate Entry NOT Found
{
InputBox, ProjectRate, Project Entry, Project Entry %Project% NOT Found for %Customer% ! Enter Project RATE($) or Cancel., ,550
IfEqual, ErrorLevel, 0 ; OK was pressed
{
IniWrite, %ProjectRate%, C:\Scripts\TimeClock\Projects.ini, %CustomerName%, %Project%
}
Else
Goto TimeClockEntry
}
}
IniWrite, %Employee%, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, Employee
IniWrite, %Customer%, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, Customer
IniWrite, %Project%, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, Project
IniWrite, %Description%, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, Description
IniDelete, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, StartTime
SetTimer, RefreshD, Off
FormatTime, StopTime, , yyyyMMddHHmmss
IniWrite, %StopTime%, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, StopTime
TimeClockString = %Employee%, %StartTime%, %StopTime%, %Customer%, %Project%, %Description%
FileAppend, %TimeClockString%`r`n, C:\Scripts\TimeClock\%A_YWeek%-TimeClock.csv
ExitApp
ButtonSTART:
Gui, Submit
IfNotEqual, StartTime
{
MsgBox, 292, TimeClock, Overwrite Existing Start Time?
IfMsgBox Yes
Goto, ContinueSTART
Else
Goto, ContinueRUNNING
}
ContinueSTART:
IniRead, CustomerName, C:\Scripts\TimeClock\Customers.ini, Customers, %Customer%
IfEqual, CustomerName, ERROR ; Customer Name NOT Found
{
InputBox, CustomerName, Customer Entry, Customer Entry %Customer% NOT Found! Enter Customer Name or Cancel., ,500
IfEqual, ErrorLevel, 0 ; OK was pressed
{
IniWrite, %CustomerName%, C:\Scripts\TimeClock\Customers.ini, Customers, %Customer%
IniRead, ProjectRate, C:\Scripts\TimeClock\Projects.ini, %CustomerName%, %Project%
IfEqual, ProjectRate, ERROR ; Project Rate Entry NOT Found
{
InputBox, ProjectRate, Project Entry, Project Entry %Project% NOT Found for %Customer% ! Enter Project RATE($) or Cancel., ,550
IfEqual, ErrorLevel, 0 ; OK was pressed
{
IniWrite, %ProjectRate%, C:\Scripts\TimeClock\Projects.ini, %CustomerName%, %Project%
}
Else
Goto TimeClockEntry
}
}
Else
{
Goto TimeClockEntry
}
}
Else ; Customer Entry Found
{
IniRead, ProjectRate, C:\Scripts\TimeClock\Projects.ini, %CustomerName%, %Project%
IfEqual, ProjectRate, ERROR ; Project Rate Entry NOT Found
{
InputBox, ProjectRate, Project Entry, Project Entry %Project% NOT Found for %Customer% ! Enter Project RATE($) or Cancel., ,550
IfEqual, ErrorLevel, 0 ; OK was pressed
{
IniWrite, %ProjectRate%, C:\Scripts\TimeClock\Projects.ini, %CustomerName%, %Project%
}
Else
Goto TimeClockEntry
}
}
FormatTime, StartTime, , yyyyMMddHHmmss
StringUpper, Employee, Employee, T
StringUpper, Customer, Customer
;StringUpper, Project, Project, T
;StringUpper, Description, Description, T
IniWrite, %Employee%, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, Employee
IniWrite, %Customer%, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, Customer
IniWrite, %Project%, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, Project
IniWrite, %Description%, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, Description
IniWrite, %StartTime%, C:\Scripts\TimeClock\TimeClock.ini, TimeClock, StartTime
ContinueRUNNING:
Gui, Destroy
Gui, +AlwaysOnTop +ToolWindow -SysMenu -Caption
WA=%A_screenwidth%
HA=%A_screenheight%
SX:=(WA*47)/100 ;x-pos
SY:=(WA*.20)/100 ;y-pos
Gui, Color, CCCCCC
Gui, Font, cFF0000 s12 , verdana ;red
;Gui, Font, c000000 s7 , verdana ;black
;Gui, Font, cFFFFFF s7 , verdana ;white
Gui, Add, Text, vD y0, %A_YYYY%-%A_MM%-%A_DD% %a_hour%:%a_min% %Project%
Gui, Show, NoActivate x%SX% y%SY%,uptime
WinSet, TransColor, CCCCCC 255,uptime
SetTimer, RefreshD, 20000
return
RefreshD:
GuiControl, , D, %A_YYYY%-%A_MM%-%A_DD% %a_hour%:%a_min% %Project%
Gui, Show, NoActivate x%SX% y%SY%,uptime
return