Skip to content

Commit 3208925

Browse files
initial upload
0 parents  commit 3208925

File tree

5 files changed

+394
-0
lines changed

5 files changed

+394
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Windows image file caches
2+
Thumbs.db
3+
ehthumbs.db
4+
5+
# Folder config file
6+
Desktop.ini
7+
8+
# Recycle Bin used on file shares
9+
$RECYCLE.BIN/
10+
11+
# Windows Installer files
12+
*.cab
13+
*.msi
14+
*.msm
15+
*.msp
16+
17+
# Windows shortcuts
18+
*.lnk
19+
20+
# =========================
21+
# Operating System Files
22+
# =========================
23+
24+
# OSX
25+
# =========================
26+
27+
.DS_Store
28+
.AppleDouble
29+
.LSOverride
30+
31+
# Thumbnails
32+
._*
33+
34+
# Files that might appear in the root of a volume
35+
.DocumentRevisions-V100
36+
.fseventsd
37+
.Spotlight-V100
38+
.TemporaryItems
39+
.Trashes
40+
.VolumeIcon.icns
41+
42+
# Directories potentially created on remote AFP share
43+
.AppleDB
44+
.AppleDesktop
45+
Network Trash Folder
46+
Temporary Items
47+
.apdisk

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# TimeTrack
2+
I wrote this little application to help me keep track of the time I spend working on tickets in a more effecient way, so that I spend less time trying to record start/end time and more time working the ticket.
3+
4+
![Shot1](https://i.imgur.com/Lwk79Ex.png)![Shot2](https://i.imgur.com/hQI2vvE.png)![Shot3](https://i.imgur.com/2gsYkTO.png)

TimeTracker.au3

+341
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,341 @@
1+
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
2+
#AutoIt3Wrapper_Icon=..\..\..\OneDrive\Pictures\TimeTracker.ico
3+
#AutoIt3Wrapper_UseX64=y
4+
#AutoIt3Wrapper_Res_SaveSource=y
5+
#AutoIt3Wrapper_Res_Language=1033
6+
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
7+
#cs ----------------------------------------------------------------------------
8+
9+
AutoIt Version: 3.3.15.0 (Beta)
10+
Author: myName
11+
12+
Script Function:
13+
Template AutoIt script.
14+
15+
#ce ----------------------------------------------------------------------------
16+
17+
; Script Start - Add your code below here
18+
#include <ButtonConstants.au3>
19+
#include <EditConstants.au3>
20+
#include <GUIConstantsEx.au3>
21+
#include <ListViewConstants.au3>
22+
#include <Excel.au3>
23+
#include <GuiListView.au3>
24+
#include <StaticConstants.au3>
25+
#include <WindowsConstants.au3>
26+
#include <GuiEdit.au3>
27+
#include <Constants.au3>
28+
#include <Misc.au3>
29+
Global $count = 0
30+
$Form1 = GUICreate("Time Tracker", 405, 429, 192, 124)
31+
$Label1 = GUICtrlCreateLabel("Time Tracker", 142, 8, 120, 29)
32+
GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
33+
$Label4 = GUICtrlCreateLabel(" 00:00:00", 72, 40, 244, 84)
34+
GUICtrlSetFont(-1, 50, 400, 0, "MS Sans Serif")
35+
$Label2 = GUICtrlCreateLabel("Project/ticket working on", 87, 90, 214, 29)
36+
GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
37+
$Input1 = GUICtrlCreateInput("", 96, 130, 201, 21)
38+
$Label3 = GUICtrlCreateLabel("All time entries", 120, 162, 130, 29)
39+
GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
40+
$ListView1 = GUICtrlCreateListView("Task|Start Time|End time|Total Time", 8, 194, 385, 175)
41+
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150)
42+
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 73)
43+
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 73)
44+
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 73)
45+
$Button1 = GUICtrlCreateButton("Start Timer", 24, 376, 89, 41, $BS_NOTIFY)
46+
GUICtrlSetCursor(-1, 0)
47+
$Button2 = GUICtrlCreateButton("Export to file", 152, 376, 89, 41, $BS_NOTIFY)
48+
GUICtrlSetCursor(-1, 0)
49+
$Button3 = GUICtrlCreateButton("Cancel", 280, 376, 81, 41, $BS_NOTIFY)
50+
GUICtrlSetCursor(-1, 0)
51+
$dummy = GUICtrlCreateDummy ()
52+
GUISetState(@SW_SHOW)
53+
#EndRegion ### END Koda GUI section ###
54+
55+
56+
While 1
57+
$x = Int(Stopwatch() / 100)
58+
$nMsg = GUIGetMsg()
59+
Switch $nMsg
60+
Case $GUI_EVENT_CLOSE
61+
If _GUICtrlListView_GetItemCount ( $ListView1 ) > 0 Then
62+
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
63+
$iMsgBoxAnswer = MsgBox($MB_YESNO + $MB_ICONQUESTION + $MB_SYSTEMMODAL,"Save info?","Do you want to save your time entries?")
64+
Select
65+
Case $iMsgBoxAnswer = $IDYES
66+
$exfile2 = FileSaveDialog ( "Name of exported document.", "", "Excel document (*.xlsx)", 18, "", $Form1 )
67+
If $exfile2 = "" Then
68+
69+
Else
70+
$num2 = _GUICtrlListView_GetItemCount ( $ListView1 )
71+
Local $array2[$num2 + 1][4]
72+
$array2[0][0] = "Task"
73+
$array2[0][1] = "Start Time"
74+
$array2[0][2] = "End Time"
75+
$array2[0][3] = "Total Time"
76+
For $y = 0 To $num2 - 1 Step 1
77+
$listarray2 = _GUICtrlListView_GetItemTextArray ( $ListView1, $y )
78+
$array2[$y + 1][0] = $listarray2[1]
79+
$array2[$y + 1][1] = $listarray2[2]
80+
$array2[$y + 1][2] = $listarray2[3]
81+
$array2[$y + 1][3] = $listarray2[4]
82+
Next
83+
$oExcel2 = _Excel_Open ()
84+
$oWorksheet2 = _Excel_BookNew ( $oExcel2 )
85+
_Excel_RangeWrite ( $oWorksheet2, Default, $array2 )
86+
_Excel_BookSaveAs ( $oWorksheet2, $exfile2 )
87+
_Excel_Close ( $oExcel2 )
88+
Exit
89+
EndIf
90+
Case $iMsgBoxAnswer = $IDNO
91+
Exit
92+
EndSelect
93+
Else
94+
Exit
95+
EndIf
96+
Case $Form1
97+
ToolTip ("")
98+
Case $Input1
99+
If _IsPressed ( "0D" ) Then
100+
ToolTip ("")
101+
Stopwatch()
102+
If @extended = 1 Then
103+
If GUICtrlRead($Input1) = "" Then
104+
$sToolTipAnswer = ToolTip("You need to specify the task in order to catalog the time.", Default, Default, "Enter task")
105+
Else
106+
Starttime(@HOUR, @MIN)
107+
GUICtrlSetData ( $Button1, "Stop Timer" )
108+
GUICtrlSetState ( $Button2, $GUI_DISABLE )
109+
GUICtrlSetData ( $Input1, "" )
110+
GUICtrlSetState ( $Input1, $GUI_DISABLE )
111+
GUICtrlSetState ( $Button3, $GUI_DISABLE )
112+
Stopwatch(1)
113+
EndIf
114+
EndIf
115+
EndIf
116+
117+
Case $Button1
118+
ToolTip ("")
119+
Stopwatch()
120+
$store = @extended
121+
If $store = 1 Then
122+
If GUICtrlRead($Input1) = "" Then
123+
$sToolTipAnswer = ToolTip("You need to specify the task in order to catalog the time.", Default, Default, "Enter task")
124+
Else
125+
Starttime(@HOUR, @MIN)
126+
GUICtrlSetData ( $Button1, "Stop Timer" )
127+
GUICtrlSetState ( $Button2, $GUI_DISABLE )
128+
GUICtrlSetData ( $Input1, "" )
129+
GUICtrlSetState ( $Input1, $GUI_DISABLE )
130+
GUICtrlSetState ( $Button3, $GUI_DISABLE )
131+
Stopwatch ( 1 )
132+
EndIf
133+
Else
134+
Endtime ( @HOUR, @MIN )
135+
GUICtrlSetData ( $Button1, "Start Timer" )
136+
GUICtrlSetState ( $Button2, $GUI_ENABLE )
137+
GUICtrlSetState ( $Button3, $GUI_ENABLE )
138+
GUICtrlSetState ( $Input1, $GUI_ENABLE )
139+
Stopwatch ( 2 )
140+
EndIf
141+
142+
143+
Case $Button2
144+
$exfile = FileSaveDialog ( "Name of exported document.", "", "PDF file (*.pdf)", 18, "", $Form1 )
145+
If $exfile = "" Then
146+
147+
Else
148+
$num = _GUICtrlListView_GetItemCount ( $ListView1 )
149+
Local $array[$num + 1][4]
150+
$array[0][0] = "Task"
151+
$array[0][1] = "Start Time"
152+
$array[0][2] = "End Time"
153+
$array[0][3] = "Total Time"
154+
For $y = 0 To $num - 1 Step 1
155+
$listarray = _GUICtrlListView_GetItemTextArray ( $ListView1, $y )
156+
$array[$y + 1][0] = $listarray[1]
157+
$array[$y + 1][1] = $listarray[2]
158+
$array[$y + 1][2] = $listarray[3]
159+
$array[$y + 1][3] = $listarray[4]
160+
Next
161+
$oExcel = _Excel_Open ()
162+
$oWorksheet = _Excel_BookNew ( $oExcel )
163+
_Excel_RangeWrite ( $oWorksheet, Default, $array )
164+
_Excel_Export ( $oExcel, $oWorksheet, $exfile, Default, Default, Default, Default, Default, True )
165+
_Excel_BookSaveAs ( $oWorksheet, _GetFilenameDrive ( $exfile ) & _GetFilenamePath ( $exfile ) & _GetFilename ( $exfile ) & ".xlsx" )
166+
_Excel_Close ( $oExcel )
167+
EndIf
168+
169+
Case $Button3
170+
If _GUICtrlListView_GetItemCount ( $ListView1 ) > 0 Then
171+
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
172+
$iMsgBoxAnswer = MsgBox($MB_YESNO + $MB_ICONQUESTION + $MB_SYSTEMMODAL,"Save info?","Do you want to save your time entries?")
173+
Select
174+
Case $iMsgBoxAnswer = $IDYES
175+
$exfile2 = FileSaveDialog ( "Name of exported document.", "", "Excel document (*.xlsx)", 18, "", $Form1 )
176+
If $exfile2 = "" Then
177+
178+
Else
179+
$num2 = _GUICtrlListView_GetItemCount ( $ListView1 )
180+
Local $array2[$num2 + 1][4]
181+
$array2[0][0] = "Task"
182+
$array2[0][1] = "Start Time"
183+
$array2[0][2] = "End Time"
184+
$array2[0][3] = "Total Time"
185+
For $y = 0 To $num2 - 1 Step 1
186+
$listarray2 = _GUICtrlListView_GetItemTextArray ( $ListView1, $y )
187+
$array2[$y + 1][0] = $listarray2[1]
188+
$array2[$y + 1][1] = $listarray2[2]
189+
$array2[$y + 1][2] = $listarray2[3]
190+
$array2[$y + 1][3] = $listarray2[4]
191+
Next
192+
$oExcel2 = _Excel_Open ()
193+
$oWorksheet2 = _Excel_BookNew ( $oExcel2 )
194+
_Excel_RangeWrite ( $oWorksheet2, Default, $array2 )
195+
_Excel_BookSaveAs ( $oWorksheet2, $exfile2 )
196+
_Excel_Close ( $oExcel2 )
197+
Exit
198+
EndIf
199+
Case $iMsgBoxAnswer = $IDNO
200+
Exit
201+
EndSelect
202+
Else
203+
Exit
204+
EndIf
205+
EndSwitch
206+
If $x <> Int(Stopwatch() / 100) Then
207+
$totsec = Int(Stopwatch() / 1000) ; ms to sec
208+
$hr = Int($totsec / 3600) ; hours
209+
$mn = Int(($totsec - ($hr * 3600)) / 60) ; minutes
210+
$sc = Int(($totsec - ($hr * 3600) - ($mn * 60))) ; seconds
211+
$tn = Int((Int(Stopwatch() / 100) - ($hr * 36000) - ($mn * 600) - ($sc * 10))) ; tenths of a second
212+
GUICtrlSetData($Label4, " " & StringFormat("%02s", $hr) & ":" & StringFormat("%02s", $mn) & ":" & StringFormat("%02s", $sc) & "." & StringFormat("%01s", $tn))
213+
If $mn >= 15 Then
214+
GUICtrlSetColor ( $Label4, 0xFF0000 )
215+
Else
216+
GUICtrlSetColor ( $Label4, 0x000000 )
217+
EndIf
218+
EndIf
219+
WEnd
220+
Func Stopwatch($ToggleTo = 4)
221+
Static Local $Paused = True
222+
Static Local $Stopwatch = 0
223+
Static Local $TotalTime = 0
224+
Switch $ToggleTo
225+
Case 0 ; pause counter
226+
If $Paused Then
227+
SetExtended($Paused) ; $Paused status
228+
Return $TotalTime ; already paused, just return current $TotalTime
229+
Else
230+
$TotalTime += TimerDiff($Stopwatch)
231+
$Paused = True
232+
SetExtended($Paused)
233+
Return $TotalTime
234+
EndIf
235+
Case 1 ; unpause counter
236+
If $Paused Then
237+
$Stopwatch = TimerInit()
238+
$Paused = False
239+
SetExtended($Paused)
240+
Return $TotalTime
241+
Else
242+
SetExtended($Paused)
243+
Return $TotalTime + TimerDiff($Stopwatch)
244+
EndIf
245+
Case 2 ; reset to 0 and pause
246+
$Paused = True
247+
$TotalTime = 0
248+
SetExtended($Paused)
249+
Return $TotalTime
250+
Case 3 ; reset to 0 and restart
251+
$Paused = False
252+
$TotalTime = 0
253+
$Stopwatch = TimerInit()
254+
SetExtended($Paused)
255+
Return $TotalTime
256+
Case 4 ; return status
257+
SetExtended($Paused)
258+
If $Paused Then
259+
Return $TotalTime
260+
Else
261+
Return $TotalTime + TimerDiff($Stopwatch)
262+
EndIf
263+
EndSwitch
264+
EndFunc ;==>Stopwatch
265+
Func Starttime($hour, $min)
266+
$pm = False
267+
$tm = ""
268+
If Int($hour) >= 12 Then
269+
$pm = True
270+
$tm = " PM"
271+
If Int($hour) > 12 Then
272+
$hour = Int($hour) - 12
273+
EndIf
274+
275+
Else
276+
$pm = False
277+
$tm = " AM"
278+
If Int($hour) = 0 Then
279+
$hour = Int($hour) + 12
280+
EndIf
281+
282+
EndIf
283+
GUICtrlCreateListViewItem(GUICtrlRead($Input1) & "|" & $hour & ":" & $min & $tm, $ListView1)
284+
EndFunc ;==>Starttime
285+
Func Endtime($hour2, $min2)
286+
$pm2 = False
287+
$tm2 = ""
288+
If Int($hour2) >= 12 Then
289+
$pm2 = True
290+
$tm2 = " PM"
291+
If Int($hour2) > 12 Then
292+
$hour2 = Int($hour2) - 12
293+
EndIf
294+
295+
Else
296+
$pm2 = False
297+
$tm2 = " AM"
298+
If Int($hour2) = 0 Then
299+
$hour2 = Int($hour2) + 12
300+
EndIf
301+
302+
EndIf
303+
$time = Int ( Round ( Stopwatch () ) ) / 1000
304+
$hr2 = Int($time / 3600) ; hours
305+
$mn2 = Int(($time - ($hr2 * 3600)) / 60) ; minutes
306+
$sc2 = Int(($time - ($hr2 * 3600) - ($mn2 * 60))) ; seconds
307+
_GUICtrlListView_AddSubItem($ListView1, $count, $hour2 & ":" & $min2 & $tm2, 2)
308+
_GUICtrlListView_AddSubItem($ListView1, $count, StringFormat("%02s", $hr2) & ":" & StringFormat("%02s", $mn2) & ":" & StringFormat("%02s", $sc2), 3)
309+
$count += 1
310+
EndFunc ;==>Endtime
311+
Func _GetFilename($sFilePath)
312+
Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2")
313+
Local $oColFiles = $oWMIService.ExecQuery("Select * From CIM_Datafile Where Name = '" & StringReplace($sFilePath, "\", "\\") & "'")
314+
If IsObj($oColFiles) Then
315+
For $oObjectFile In $oColFiles
316+
Return $oObjectFile.FileName
317+
Next
318+
EndIf
319+
Return SetError(1, 1, 0)
320+
EndFunc ;==>_GetFilename
321+
Func _GetFilenameDrive($sFilePath)
322+
Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2")
323+
Local $oColFiles = $oWMIService.ExecQuery("Select * From CIM_Datafile Where Name = '" & StringReplace($sFilePath, "\", "\\") & "'")
324+
If IsObj($oColFiles) Then
325+
For $oObjectFile In $oColFiles
326+
Return StringUpper($oObjectFile.Drive)
327+
Next
328+
EndIf
329+
Return SetError(1, 1, 0)
330+
EndFunc ;==>_GetFilenameDrive
331+
332+
Func _GetFilenamePath($sFilePath)
333+
Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2")
334+
Local $oColFiles = $oWMIService.ExecQuery("Select * From CIM_Datafile Where Name = '" & StringReplace($sFilePath, "\", "\\") & "'")
335+
If IsObj($oColFiles) Then
336+
For $oObjectFile In $oColFiles
337+
Return $oObjectFile.Path
338+
Next
339+
EndIf
340+
Return SetError(1, 1, 0)
341+
EndFunc ;==>_GetFilenamePath

TimeTracker.exe

1.4 MB
Binary file not shown.

0 commit comments

Comments
 (0)