;StartClock - Build 18 ;Revisions will go up by one increment in each new build ;Checks to see if StartClock is already running If WinExists ( "%_StartClock_%" ) Then WinKill ( "%_StartClock_%" ) EndIf AutoItWinSetTitle ( "%_StartClock_%" ) If NOT FileExists ( @ScriptDir & "\StartClock.ini" ) Then Config() $HideTrayIcon = IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "HideTrayIcon", "4" ) If $HideTrayIcon = 1 Then $HideTrayIcon = 0 ElseIf $HideTrayIcon = 4 Then $HideTrayIcon =1 EndIf Opt ( "TrayIconHide", $HideTrayIcon ) Opt ( "WinTitleMatchMode", 4 ) Opt ( "WinTextMatchMode", 2 ) ;VARIABLES $Button1TXT = ControlGetText ( "classname=Shell_TrayWnd", "", "Button1" ) ;Start Button $Button1POS = ControlGetPos( "classname=Shell_TrayWnd", "", "Button1" ) ;Start Button NEW replace $Button1POS eventually $ReBarPOS = ControlGetPos ( "classname=Shell_TrayWnd", "", "ReBarWindow321" ) ;entire runningApp and quicklaunch area $GetTime = FileGetTime ( @ScriptDir & "\StartClock.ini", 0 , 1) $ClockType = IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "ClockType", "1" ) $ShowDate = IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "ShowDate", "4" ) $ShowSeconds = IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "ShowSeconds", "4" ) If IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "DisableHotkeys", "4" ) = 4 Then HotKeySet( "^!x", "ExitScript" ); CTRL+ALT+X HotKeySet( "^!c", "Config" ); CTRL+ALT+C Else HotKeySet( "^!x" ) HotKeySet( "^!c" ) EndIf Do ;DYNAMIC OPTIONS If FileGetTime( @ScriptDir & "\StartClock.ini", 0 , 1) <> $GetTime Then $ClockType = IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "ClockType", "1" ) $ShowDate = IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "ShowDate", "4" ) $ShowSeconds = IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "ShowSeconds", "4" ) $HideTrayIcon = IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "HideTrayIcon", "0" ) If $HideTrayIcon = 1 Then $HideTrayIcon = 0 ElseIf $HideTrayIcon = 4 Then $HideTrayIcon =1 EndIf Opt ( "TrayIconHide", $HideTrayIcon ) If IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "BeginAtStartup", "0" ) = 1 Then RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "StartClock", "REG_SZ", @ScriptFullPath ) Else RegDelete ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "StartClock" ) EndIf If IniRead ( @ScriptDir & "\StartClock.ini", "Settings", "DisableHotkeys", "4" ) = 4 Then HotKeySet( "^!x", "ExitScript" ); CTRL+ALT+X HotKeySet( "^!c", "Config" ); CTRL+ALT+C Else HotKeySet( "^!x" ) HotKeySet( "^!c" ) EndIf EndIf ;SET SECONDS PROPERTIES If $ShowSeconds = 1 Then If $ClockType = 4 Then $Sec = ":" & @sec Else $Sec = ":" & @Sec EndIf Else If $ClockType = 4 Then $Sec = "" Else $Sec = "" EndIf EndIf ;SET DATE PROPERTIES If $ShowDate = 1 Then If @mon = 1 then $mon = "Jan" ElseIf @mon = 2 then $mon = "Feb" ElseIf @mon = 3 then $mon = "Mar" ElseIf @mon = 4 then $mon = "Apr" ElseIf @mon = 5 then $mon = "May" ElseIf @mon = 6 then $mon = "June" ElseIf @mon = 7 then $mon = "July" ElseIf @mon = 8 then $mon = "Aug" ElseIf @mon = 9 then $mon = "Sept" ElseIf @mon = 10 then $mon = "Oct" ElseIf @mon = 11 then $mon = "Nov" ElseIf @mon = 12 then $mon = "Dec" EndIf $Date = " - " & $MON & " " & @MDAY Else $Date = "" EndIf ;SET TIME PROPERTIES If $ClockType = 1 Then 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 $Time = $Hour & ":" & @Min & $Sec & $AMPM & $Date Else $Time = @Hour & ":" & @Min & $Sec & $Date EndIf AdLibEnable( "ResizBtn", 1) Sleep(1000) Until 1 <> 1 ;FUNCTIONS Func ResizBtn() $Btn_Sized = StringLen(String($Time))*6 If $ShowDate = 1 Then $Btn_Sized = $Btn_Sized + (StringLen(String($Date))*1.5) $TrayNEW = controlgetpos("classname=Shell_TrayWnd", "", "ReBarWindow321") If $ReBarPOS[3] <> $TrayNEW[3] Then Opt ( "TrayIconHide", 0 ) Opt ( "TrayIconHide", 1 ) Opt ( "TrayIconHide", $HideTrayIcon ) $Button1TXT = ControlGetText ( "classname=Shell_TrayWnd", "", "Button1" ) ;Start Button $Button1POS = ControlGetPos( "classname=Shell_TrayWnd", "", "Button1" ) ;Start Button NEW replace $Button1POS eventually $ReBarPOS = ControlGetPos ( "classname=Shell_TrayWnd", "", "ReBarWindow321" ) ;entire runningApp and quicklaunch area EndIf If $ReBarPOS[2] > $ReBarPOS[3] Then ;entire tray width greater than height ControlMove("classname=Shell_TrayWnd", "", "ReBarWindow321", $ReBarPOS[0]+$Btn_Sized, $ReBarPOS[1], $ReBarPOS[2]-$Btn_Sized, $ReBarPOS[3]) EndIf ControlMove("classname=Shell_TrayWnd", "", "Button1", $Button1POS[0], $Button1POS[1], $Button1POS[2]+$Btn_Sized, $Button1POS[3]) ;x, y, width, height ControlSetText("classname=Shell_TrayWnd", "", "Button1", $Time) EndFunc Func Config() If FileExists( @ScriptDir & "\options_GUI.exe") Then Run ( "options_GUI.exe", @ScriptDir ) EndIf EndFunc Func ExitScript() AdLibDisable() $TrayPOS = controlgetpos("classname=Shell_TrayWnd", "", "") If $TrayPOS[2] > $TrayPOS[3] Then ControlMove("classname=Shell_TrayWnd", "", "ReBarWindow321", $ReBarPOS[0], $ReBarPOS[1], $ReBarPOS[2], $ReBarPOS[3]) EndIf ControlSetText( "classname=Shell_TrayWnd", "", "Button1", $Button1TXT ) ControlMove( "classname=Shell_TrayWnd", "", "Button1", $Button1POS[0], $Button1POS[1], $Button1POS[2], $Button1POS[3] ) WinKill ( "%_StartClock_%" ) EndFunc