Creating an Excel spreadsheet with AHK timer functionality sounds great. I did spend countless hours creating an AHK script with multiple stopwatch functions, but it was buggy and inconsistent.
I'd be grateful for a simpler, more consistent script which would interact with Excel in the way you described.
Code: Select all
#NoEnv
#singleinstance force
Menu, Tray, Icon, C:\windows\system32\shell32.dll,263 ;Set custom Script icon
Settimer, Stopwatch, off
timerm := "00"
timers := "00"
stopped := "0"
timerm1 := "00"
timers1 := "00"
stopped1 := "0"
timerm2 := "00"
timers2 := "00"
stopped2 := "0"
timerm3 := "00"
timers3 := "00"
stopped3 := "0"
timerm4 := "00"
timers4 := "00"
stopped4 := "0"
timerm5 := "00"
timers5 := "00"
stopped5 := "0"
timerm6 := "00"
timers6 := "00"
stopped6 := "0"
timerm7 := "00"
timers7 := "00"
stopped7 := "0"
timerm8 := "00"
timers8 := "00"
stopped8 := "0"
timerm9 := "00"
timers9 := "00"
stopped9 := "0"
timerm10 := "00"
timers10 := "00"
stopped10 := "0"
Gui, Add, Text, x85 y5 w160 h20 vStartTime, Start = %StartTime%
Gui, Add, Text, x40 y52 w160 h20 vStopTime, Stop = %StopTime%
Gui, Add, Text, x155 y30 w60 h20 vTText, %timerm%:%timers%
Gui, Add, Text, x155 y70 w60 h20 vTText1, %timerm1%:%timers1%
Gui, Add, Text, x155 y110 w60 h20 vTText2, %timerm2%:%timers2%
Gui, Add, Text, x155 y150 w60 h20 vTText3, %timerm3%:%timers3%
Gui, Add, Text, x155 y190 w60 h20 vTText4, %timerm4%:%timers4%
Gui, Add, Text, x155 y230 w60 h20 vTText5, %timerm5%:%timers5%
Gui, Add, Text, x155 y270 w60 h20 vTText6, %timerm6%:%timers6%
Gui, Add, Text, x155 y310 w60 h20 vTText7, %timerm7%:%timers7%
Gui, Add, Text, x155 y350 w60 h20 vTText8, %timerm8%:%timers8%
Gui, Add, Text, x155 y390 w60 h20 vTText9, %timerm9%:%timers9%
Gui, Add, Text, x155 y430 w60 h20 vTText10, %timerm10%:%timers10%
;Gui, Add, Button, x2 y42 w80 h20 vPause, Pause
;Gui, Add, Button, x82 y42 w80 h20 vReset, Reset
Gui, Add, Button, x22 y20 w90 h30 gThe_Main_Gui_StopStart1 , &1
gui, add, edit, x220 y20 w760 h30 vMyEdit1
Gui, Add, Button, x22 y60 w90 h30 gThe_Main_Gui_StopStart2 , &2
gui, add, edit, x220 y60 w760 h30 vMyEdit2
Gui, Add, Button, x22 y100 w90 h30 gThe_Main_Gui_StopStart3 , &3
gui, add, edit, x220 y100 w760 h30 vMyEdit3
Gui, Add, Button, x22 y140 w90 h30 gThe_Main_Gui_StopStart4 , &4
gui, add, edit, x220 y140 w760 h30 vMyEdit4
Gui, Add, Button, x22 y180 w90 h30 gThe_Main_Gui_StopStart5 , &5
gui, add, edit, x220 y180 w760 h30 vMyEdit5
Gui, Add, Button, x22 y220 w90 h30 gThe_Main_Gui_StopStart6 , &6
gui, add, edit, x220 y220 w760 h30 vMyEdit6
Gui, Add, Button, x22 y260 w90 h30 gThe_Main_Gui_StopStart7 , &7
gui, add, edit, x220 y260 w760 h30 vMyEdit7
Gui, Add, Button, x22 y300 w90 h30 gThe_Main_Gui_StopStart8 , &8
gui, add, edit, x220 y300 w760 h30 vMyEdit8
Gui, Add, Button, x22 y340 w90 h30 gThe_Main_Gui_StopStart9 , &9
gui, add, edit, x220 y340 w760 h30 vMyEdit9
Gui, Add, Button, x22 y380 w90 h30 gThe_Main_Gui_StopStart10 , &10
gui, add, edit, x220 y380 w760 h30 vMyEdit10
Gui, Add, Button, x22 y480 w90 h30 gDataSave, &Save Data
Gui, Add, Button, x130 y480 w90 h30 gScratchy, Show Scratch
Gui, Add, Button, x238 y480 w90 h30 gClearScratch, Clear Scratch
; Gui, Add, Button, x248 y500 w90 h30 gThe_Main_Gui_Close, &Quit and Save
gui, add, edit, x10 y600 w980 h90 vMyEdit
Gui, Show, h700 w1000, Stopwatch
Return
Stopwatch:
timers += 1
if(timers > 59)
{
timerm += 1
timers := "0"
GuiControl, , TText , %timerm%:%timers%
}
if(timers < 10)
{
GuiControl, , TText , %timerm%:0%timers%
}
else
{
GuiControl, , TText , %timerm%:%timers%
}
return
Stopwatch1:
timers1 += 1
if(timers1 > 59)
{
timerm1 += 1
timers1 := "0"
GuiControl, , TText1 , %timerm1%:%timers1%
}
if(timers < 10)
{
GuiControl, , TText1 , %timerm1%:0%timers1%
}
else
{
GuiControl, , TText1 , %timerm1%:%timers1%
}
return
Stopwatch2:
timers2 += 1
if(timers2 > 59)
{
timerm2 += 1
timers2 := "0"
GuiControl, , TText2 , %timerm2%:%timers2%
}
if(timers < 10)
{
GuiControl, , TText2 , %timerm%:0%timers2%
}
else
{
GuiControl, , TText2 , %timerm%:%timers2%
}
return
Stopwatch3:
timers3 += 1
if(timers3 > 59)
{
timerm3 += 1
timers3 := "0"
GuiControl, , TText3 , %timerm3%:%timers3%
}
if(timers < 10)
{
GuiControl, , TText3 , %timerm3%:0%timers3%
}
else
{
GuiControl, , TText3 , %timerm3%:%timers3%
}
return
Stopwatch4:
timers4 += 1
if(timers4 > 59)
{
timerm4 += 1
timers4 := "0"
GuiControl, , TText4 , %timerm4%:%timers4%
}
if(timers < 10)
{
GuiControl, , TText4 , %timerm4%:0%timers4%
}
else
{
GuiControl, , TText4 , %timerm4%:%timers4%
}
return
Stopwatch5:
timers5 += 1
if(timers5 > 59)
{
timerm5 += 1
timers5 := "0"
GuiControl, , TText5 , %timerm5%:%timers5%
}
if(timers < 10)
{
GuiControl, , TText5 , %timerm5%:0%timers5%
}
else
{
GuiControl, , TText5 , %timerm5%:%timers5%
}
return
Stopwatch6:
timers6 += 1
if(timers6 > 59)
{
timerm6 += 1
timers6 := "0"
GuiControl, , TText6 , %timerm6%:%timers6%
}
if(timers < 10)
{
GuiControl, , TText6 , %timerm6%:0%timers6%
}
else
{
GuiControl, , TText6 , %timerm7%:%timers6%
}
return
Stopwatch7:
timers7 += 1
if(timers7 > 59)
{
timerm7 += 1
timers7 := "0"
GuiControl, , TText7 , %timerm7%:%timers7%
}
if(timers < 10)
{
GuiControl, , TText7 , %timerm7%:0%timers7%
}
else
{
GuiControl, , TText7 , %timerm7%:%timers7%
}
return
Stopwatch8:
timers8 += 1
if(timers8 > 59)
{
timerm8 += 1
timers8 := "0"
GuiControl, , TText8 , %timerm8%:%timers8%
}
if(timers < 10)
{
GuiControl, , TText8 , %timerm8%:0%timers8%
}
else
{
GuiControl, , TText8 , %timerm8%:%timers8%
}
return
Stopwatch9:
timers9 += 1
if(timers9 > 59)
{
timerm9 += 1
timers9 := "0"
GuiControl, , TText9 , %timerm9%:%timers9%
}
if(timers < 10)
{
GuiControl, , TText09 , %timerm9%:0%timers9%
}
else
{
GuiControl, , TText9 , %timerm9%:%timers9%
}
return
Stopwatch10:
timers10 += 1
if(timers10 > 59)
{
timerm10 += 1
timers10 := "0"
GuiControl, , TText10 , %timerm10%:%timers10%
}
if(timers < 10)
{
GuiControl, , TText10 , %timerm10%:0%timers10%
}
else
{
GuiControl, , TText10 , %timerm10%:%timers10%
}
return
The_Main_Gui_StopStart1:
if(stopped = 0)
{
Settimer, Stopwatch, off
stopped = 1
}
else
{
Settimer, Stopwatch, 999
stopped = 0
}
return
The_Main_Gui_StopStart2:
if(stopped = 0)
{
Settimer, Stopwatch1, off
stopped = 1
}
else
{
Settimer, Stopwatch1, 999
stopped = 0
}
return
The_Main_Gui_StopStart3:
if(stopped = 0)
{
Settimer, Stopwatch2, off
stopped = 1
}
else
{
Settimer, Stopwatch2, 999
stopped = 0
}
return
The_Main_Gui_StopStart4:
if(stopped = 0)
{
Settimer, Stopwatch3, off
stopped = 1
}
else
{
Settimer, Stopwatch3, 999
stopped = 0
}
return
The_Main_Gui_StopStart5:
if(stopped = 0)
{
Settimer, Stopwatch4, off
stopped = 1
}
else
{
Settimer, Stopwatch4, 999
stopped = 0
}
return
The_Main_Gui_StopStart6:
if(stopped = 0)
{
Settimer, Stopwatch5, off
stopped = 1
}
else
{
Settimer, Stopwatch5, 999
stopped = 0
}
return
The_Main_Gui_StopStart7:
if(stopped = 0)
{
Settimer, Stopwatch6, off
stopped = 1
}
else
{
Settimer, Stopwatch6, 999
stopped = 0
}
return
The_Main_Gui_StopStart8:
if(stopped = 0)
{
Settimer, Stopwatch7, off
stopped = 1
}
else
{
Settimer, Stopwatch7, 999
stopped = 0
}
return
The_Main_Gui_StopStart9:
if(stopped = 0)
{
Settimer, Stopwatch8, off
stopped = 1
}
else
{
Settimer, Stopwatch8, 999
stopped = 0
}
return
The_Main_Gui_StopStart10:
if(stopped = 0)
{
Settimer, Stopwatch9, off
stopped = 1
}
else
{
Settimer, Stopwatch9, 999
stopped = 0
}
return
;@
DataSave:
Gui, Submit, NoHide
Send ^!{PrintScreen} ; Same as writing Send {Ctrl}{Alt}{PrintScreen}
Sleep, 3500
BillableTime1:=timerm1 / 60
BillableTime2:=timerm2 / 60
BillableTime3:=timerm3 / 60
BillableTime4:=timerm4 / 60
BillableTime5:=timerm5 / 60
BillableTime6:=timerm6 / 60
BillableTime7:=timerm7 / 60
BillableTime8:=timerm8 / 60
BillableTime9:=timerm9 / 60
BillableTime10:=timerm10 / 60
fileappend, %A_MM% %A_DD% %A_YYYY% %A_Hour%:%A_Min% `r`n %MyEdit1% %timerm1%:%timers1% equals %BillableTime1% `r`n %MyEdit2% %timerm2%:%timers2% %BillableTime2% `r`n %MyEdit3% %timerm3%:%timers3% %BillableTime3% `r`n %MyEdit4% %timerm4%:%timers4% %BillableTime4% `r`n %MyEdit5% %timerm5%:%timers5% %BillableTime5% `r`n %MyEdit6% %timerm6%:%timers6% %BillableTime6% `r`n %MyEdit7% %timerm7%:%timers7% %BillableTime7% `r`n %MyEdit8% %timerm8%:%timers8% %BillableTime8% `r`n %MyEdit9% %timerm9%:%timers9% %BillableTime9% `r`n %MyEdit10% %timerm10%:%timers10% %BillableTime10% `r`n %MyEdit%, C:\Users\MyName\OneDrive\Desktop\Scratchpad.txt
Sleep, 1000
Return
Scratchy:
Gui, Submit, NoHide
Run C:\Users\MyName\OneDrive\Desktop\Scratchpad.txt
Return
ClearScratch:
FileDelete, C:\Users\MyName\OneDrive\Desktop\Scratchpad.txt
IfNotExist, C:\Users\MyName\OneDrive\Desktop\Scratchpad.txt, FileAppend,, C:\Users\MyName\OneDrive\Desktop\Scratchpad.txt
return
;@
;The_Main_Gui_Close:
; GUI, Submit
; Sleep, 1000
; fileappend, %A_MM% %A_DD% %A_YYYY% %A_Hour%:%A_Min% `r`n %MyEdit1% %A_Space% %timerm1%:%timers1% `r`n %MyEdit2% %A_Space% %timerm2%:%timers2% `r`n %MyEdit3% %A_Space% %timerm3%:%timers3% `r`n %MyEdit4% %A_Space% %timerm4%:%timers4% `r`n %MyEdit5% %A_Space% %timerm5%:%timers5% `r`n %MyEdit6% %A_Space% %timerm6%:%timers6% `r`n %MyEdit7% %A_Space% %timerm7%:%timers7% `r`n %MyEdit8% %A_Space% %timerm8%:%timers8% `r`n %MyEdit9% %A_Space% %timerm9%:%timers9% `r`n %MyEdit10% %A_Space% %timerm10%:%timers10% `r`n, C:\Users\MyName\OneDrive\Desktop\Scratchpad.txt
;Sleep, 1000
;Return
;Exitapp
ButtonPause:
if(stopped = 0)
{
Settimer, Stopwatch, off
stopped = 1
}
else
{
Settimer, Stopwatch, 999
stopped = 0
}
return
ButtonReset:
timerm := "00"
timers := "00"
GuiControl, , TText , %timerm%:%timers%
return
GuiClose:
GuiEscape:
ExitApp
return