$DisableTrayIcon = IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "DisableTrayIcon", "1" ) Opt ( "TrayIconHide", $DisableTrayIcon ) Opt ( "WinTitleMatchMode", 4 ) Opt ( "WinTextMatchMode", 2 ) ; Checks to see if StartClock is already running If WinExists ( "_StartClock" ) Then MsgBox ( 0, "StartClock", "Only one copy of StartClock can be run at once." ) Exit EndIf AutoItWinSetTitle ( "_StartClock" ) HotKeySet( "^!x", "ExitScript" ); CTRL+ALT+X HotKeySet( "^!d", "ShowDate" ); CTRL+ALT+D HotKeySet( "^!t", "HideTrayC" ); CTRL+ALT+T ;Variables List $OldBtnPos = controlgetpos( "classname=Shell_TrayWnd", "", "Button1" ) ; Gets original size of the start button $TrayPos = controlgetpos( "classname=Shell_TrayWnd", "", "" ) ; Gets original size of the tray $Button1txt = ControlGetText ( "classname=Shell_TrayWnd", "", "Button1" ) $24HourClock = IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "24HourClock", "0" ) $12HourClock_WithSeconds = IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "12HourClock_WithSeconds", "0" ) $Refresh_Rate = IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "Refresh_Rate", "10000" ) AdLibEnable( "ResizBtn", 0 ) If $24HourClock = 1 Then For $i = 0 To 86400 $Time = @Hour & ":" & @Min ControlSetText("classname=Shell_TrayWnd", "", "Button1", $Time) ; displays time Sleep ( 60000 - (1000 * @SEC) ) ; Pauses script based on time until next minute AdLibEnable ( "ResizBtn", $Refresh_Rate ) Next EndIf If $24HourClock = 0 Then For $i = 0 To 86400 If @HOUR <= 11 AND Not @HOUR = 00 Then $Hour = 24 + @HOUR - 24 $AMPM = " AM" ElseIf @HOUR > 12 Then $Hour = @HOUR - 12 $AMPM = " PM" ElseIf @HOUR = 12 Then $Hour = @HOUR $AMPM = " PM" ElseIf @HOUR = 00 Then $Hour = "12" $AMPM = " AM" EndIf If $12HourClock_WithSeconds = 0 Then $Time = $Hour & ":" & @Min & $AMPM ElseIf $12HourClock_WithSeconds = 1 Then $Time = $Hour & ":" & @Min & ":" & @Sec & $AMPM EndIf ControlSetText("classname=Shell_TrayWnd", "", "Button1", $Time) ; displays time If $12HourClock_WithSeconds = 0 Then Sleep ( 60000 - (1000 * @SEC) ) ; Pauses script based on time until next minute AdLibEnable ( "ResizBtn", $Refresh_Rate ) EndIf Next EndIf ;Functions List Func ResizBtn() If $24HourClock = 0 Then If $12HourClock_WithSeconds = 0 Then ControlMove("classname=Shell_TrayWnd", "", "Button1", $OldBtnPos[0], $OldBtnPos[1], $OldBtnPos[2]*1.4) ElseIf $12HourClock_WithSeconds = 1 Then ControlMove("classname=Shell_TrayWnd", "", "Button1", $OldBtnPos[0], $OldBtnPos[1], $OldBtnPos[2]*1.7) EndIf ElseIf $24HourClock = 1 Then ControlMove("classname=Shell_TrayWnd", "", "Button1", $OldBtnPos[0], $OldBtnPos[1], $OldBtnPos[2]*1.1) EndIf ; Compare horizontal size of the tray to vertical and resizes properly $TrayPos = controlgetpos("classname=Shell_TrayWnd", "", "") ; Gets size of the tray If $TrayPos[2] > $TrayPos[3] Then If $24HourClock = 0 Then If $12HourClock_WithSeconds = 0 Then ControlMove("classname=Shell_TrayWnd", "", "ReBarWindow321", $OldBtnPos[2]*1.45, 0) ElseIf $12HourClock_WithSeconds = 1 Then ControlMove("classname=Shell_TrayWnd", "", "ReBarWindow321", $OldBtnPos[2]*1.75, 0) EndIf ElseIf $24HourClock = 1 Then ControlMove("classname=Shell_TrayWnd", "", "ReBarWindow321", $OldBtnPos[2]*1.15, 0) EndIf EndIf ControlSetText("classname=Shell_TrayWnd", "", "Button1", $Time) ; displays time EndFunc Func HideTrayC() ; Hides tray clock $TCV = RegRead ( "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "HideClock" ) If $TCV = 1 Then RegWrite ( "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "HideClock", "REG_DWORD", 0 ) MsgBox ( 0, "StartClock", "Tray clock now visible. Windows must be restarted for changes to take effect." ) EndIf If $TCV = 0 Then RegWrite ( "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "HideClock", "REG_DWORD", 1 ) MsgBox ( 0, "StartClock", "Tray clock now hidden. Windows must be restarted for changes to take effect." ) EndIf EndFunc Func ShowDate() ; Displays date menu Run ("rundll32.exe shell32.dll,Control_RunDLL timedate.cpl") EndFunc Func ExitScript() AdLibDisable() If $TrayPos[2] > $TrayPos[3] Then ControlMove( "classname=Shell_TrayWnd", "", "ReBarWindow321", $OldBtnPos[2]+$OldBtnPos[2]*0.06, 0 ) EndIf ControlSetText( "classname=Shell_TrayWnd", "", "Button1", $Button1txt ) ControlMove( "classname=Shell_TrayWnd", "", "Button1", $OldBtnPos[0], $OldBtnPos[1], $OldBtnPos[2], $OldBtnPos[3] ) Exit EndFunc Exit