If WinExists("%_StartClock_%") Then ;Checks to see if StartClock is already running Exit EndIf ;//setting environment variables// #include Opt("GuiOnEventMode", 1) Opt("GUICoordMode", 1) Opt ("WinTitleMatchMode", 4) Opt ("WinTextMatchMode", 2) ;Opt ("WinWaitDelay", 300) AutoItWinSetTitle("%_StartClock_%") ProcessSetPriority("StartClock.exe", 0) $Button1_pos = ControlGetPos( "classname=Shell_TrayWnd", "", "Button1") ;find and store location of button1(start button) $tray_pos = ControlGetPos("classname=Shell_TrayWnd", "", "ReBarWindow321") ;entire task and quicklaunch area $GetTime = FileGetTime(@ScriptDir & "\StartClock.ini", 0, 1) ;store startclock.ini last modified $date = "" $AMPM = "" $hour = "" $min = "" $sec = "" $display = "" If FileExists(@ScriptDir & "\StartClock.ini") Then ReadINI() Else MakeINI() EndIf Opt ("TrayIconHide", $HideTrayIcon) If $BeginAtStartup = 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 $DisableHotkeys = 4 Then HotKeySet("^!x", "ExitScript");CTRL+ALT+X HotKeySet("^!c", "Config");CTRL+ALT+C HotKeySet("^!+d", "Debug");CTRL+ALT+D EndIf ;//end// ResizBtn() AdlibEnable( "Watch", 250) Do $timer = TimerStart() $HOUR = @HOUR $MIN = @MIN ;//wait for changes in startclock.ini// If FileGetTime(@ScriptDir & "\StartClock.ini", 0, 1) <> $GetTime Then ReadINI() If $HideTrayIcon = 4 Then $HideTrayIcon = 1;hide tray icon Else $HideTrayIcon = 0;show tray icon EndIf Opt ("TrayIconHide", $HideTrayIcon) If $BeginAtStartup = 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 $DisableHotkeys = 4 Then HotKeySet("^!x", "ExitScript");CTRL+ALT+X HotKeySet("^!c", "Config");CTRL+ALT+C HotKeySet("^!+d", "Debug");CTRL+ALT+D Else HotKeySet("^!x") HotKeySet("^!c") HotKeySet("^!+d") EndIf $GetTime = FileGetTime(@ScriptDir & "\StartClock.ini", 0, 1) EndIf ;//end// ;//define seconds// If $ShowSeconds = 1 Then $SEC = ":" & @SEC Else $SEC = "" EndIf ;//end// ;//define date// If $Showdate = 1 Then Calldate() Else $date = "" EndIf ;//end// ;//define hours// 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 Else $AMPM = "" EndIf ;//end// $test = TimerStart() ;;MsgBox(0, "Debug - Calculation Time", TimerDiff($timer)) If TimerDiff($timer) > 1 Then ;;MsgBox(0, "Debug - Verify Run", "Time Lag corrected") $sec = @SEC $display = $HOUR & ":" & $MIN & $SEC & $AMPM & $date Else $display = $HOUR & ":" & $MIN & $SEC & $AMPM & $date Sleep(1000 - TimerDiff($timer)) EndIf Until 1 <> 1 ;//begin functions// Func Watch() If ControlGetPos( "classname=Shell_TrayWnd", "", "Button1") <> $Pre_Watch Then ResizBtn() EndIf EndFunc ;//note: x, y, width, height// Func ResizBtn() $thin_siz = StringSplit($hour & ":" & $min & $sec & $ampm & $date, "fijl :-") $med_siz = StringSplit($hour & ":" & $min & $sec & $ampm & $date, "abcdeghknopqrstuvxyz") $wide_siz = StringSplit($hour & ":" & $min & $sec & $ampm & $date, "0123456789mwABCDEFGHIJKLMNOPQRSTUVWXYZ") $resize = ($thin_siz[0]-1) * ($button1_pos[3] * 0.125) + ($med_siz[0]-1) * ($button1_pos[3] * 0.3125) + ($wide_siz[0]-1) * ($button1_pos[3] * 0.40625) $tray_current = ControlGetPos("classname=Shell_TrayWnd", "", "ReBarWindow321") If $tray_pos[3] <> $tray_current[3] Then RefreshTray();drastic theme changes If $tray_pos[2] > $tray_pos[3] Then;entire tray width greater than height ControlMove("classname=Shell_TrayWnd", "", "ReBarWindow321", $tray_pos[0] - $Button1_pos[2] + ($Button1_pos[2] * 0.58 + $resize), $tray_pos[1], $tray_pos[2] + $Button1_pos[2] - ($Button1_pos[2] * 0.58 + $resize), $tray_pos[3]);resizes tray EndIf ControlMove("classname=Shell_TrayWnd", "", "Button1", $Button1_pos[0], $Button1_pos[1], ($Button1_pos[2] * 0.58 + $resize), $Button1_pos[3]);resizes start button ControlSetText("classname=Shell_TrayWnd", "", "Button1", $display) GLOBAL $Pre_Watch = ControlGetPos( "classname=Shell_TrayWnd", "", "Button1") EndFunc Func Debug() $thin_siz = StringSplit($hour & ":" & $min & $sec & $ampm & $date, "fijl :-") $med_siz = StringSplit($hour & ":" & $min & $sec & $ampm & $date, "abcdeghknopqrstuvxyz") $wide_siz = StringSplit($hour & ":" & $min & $sec & $ampm & $date, "0123456789mwABCDEFGHIJKLMNOPQRSTUVWXYZ") $posrefill = ControlGetPos("classname=Shell_TrayWnd", "", "Button1") $resize = ($thin_siz[0]-1) * ($button1_pos[3] * 0.125) + ($med_siz[0]-1) * ($button1_pos[3] * 0.3125) + ($wide_siz[0]-1) * ($button1_pos[3] * 0.375) ;0.40625) MsgBox(0, "Debug - Characters", "Start Height: " & $button1_pos[3] & @LF & "Start Width: " & $button1_pos[2] & @LF & @LF & "Thin Char: " & $thin_siz[0]-1 & @LF & "Med Char: " & $med_siz[0]-1 & @LF & "Wide Char: " & $wide_siz[0]-1 & @LF & "Char Space: " & $resize & @LF & @LF &"Actual space taken: " & $posrefill[2]) EndFunc Func Calldate() 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 EndFunc Func RefreshTray() ProcessWaitClose( "net.exe" ) Sleep(250) Opt ("TrayIconHide", 0) Opt ("TrayIconHide", 1) Opt ("TrayIconHide", $HideTrayIcon) $Button1TXT = ControlGetText("classname=Shell_TrayWnd", "", "Button1") ;Start Button $Button1_pos = ControlGetPos( "classname=Shell_TrayWnd", "", "Button1") ;Start Button NEW replace $Button1_pos eventually $tray_pos = ControlGetPos("classname=Shell_TrayWnd", "", "ReBarWindow321") ;entire runningApp and quicklaunch area EndFunc Func ReadINI() GLOBAL $ShowSeconds = IniRead(@ScriptDir & "\StartClock.ini", "Settings", "ShowSeconds", "4") GLOBAL $ClockType = IniRead(@ScriptDir & "\StartClock.ini", "Settings", "ClockType", "1") GLOBAL $Showdate = IniRead(@ScriptDir & "\StartClock.ini", "Settings", "ShowDate", "4") GLOBAL $HideTrayIcon = IniRead(@ScriptDir & "\StartClock.ini", "Settings", "HideTrayIcon", "4") GLOBAL $BeginAtStartup = IniRead(@ScriptDir & "\StartClock.ini", "Settings", "BeginAtStartup", "4") GLOBAL $DisableHotkeys = IniRead(@ScriptDir & "\StartClock.ini", "Settings", "DisableHotkeys", "4") EndFunc ;//note: x, y, width, height// Func MakeINI() GuiCreate("StartClock Configuration", 248, 155,(@DesktopWidth-248)/2, (@DesktopHeight-155)/2 , 0x12CA0000) GUISetState (@SW_SHOW) $about_menu = GUICtrlCreateMenuitem ("&About", -1) $Label_Options = GuiCtrlCreateLabel("Options:", 15, 5, 60, 20, 0x08000000) GLOBAL $Radio_12Hour = GuiCtrlCreateRadio("12 Hour Clock", 15, 23, 100, 20) GLOBAL $Radio_24Hour = GuiCtrlCreateRadio("24 Hour Clock", 15, 43, 90, 20) GLOBAL $Checkbox_ShowSeconds = GuiCtrlCreateCheckbox("Show Seconds", 15, 63, 90, 20) GLOBAL $Checkbox_Showdate = GuiCtrlCreateCheckbox("Show date", 15, 83, 70, 20) GLOBAL $Checkbox_Tray = GuiCtrlCreateCheckbox("Show Tray Icon", 140, 23, 100, 20) GLOBAL $Checkbox_Startup = GuiCtrlCreateCheckbox("Begin at Startup", 140, 43, 100, 20) GLOBAL $Checkbox_Hotkeys = GuiCtrlCreateCheckbox("Disable Hotkeys", 140, 63, 100, 20) GLOBAL $Exit1 = GuiCtrlCreateButton("Exit", 78, 110, 90, 20) If FileExists (@ScriptDir & "\StartClock.ini") Then ReadINI() If $ClockType = 4 Then GUICtrlSetState($Radio_24Hour, 1) Else GUICtrlSetState($Radio_12Hour, 1) EndIf GUICtrlSetState ( $Checkbox_ShowSeconds, $ShowSeconds ) GUICtrlSetState ( $Checkbox_Showdate, $Showdate ) GUICtrlSetState ( $Checkbox_Tray, $HideTrayIcon ) GUICtrlSetState ( $Checkbox_Startup, $BeginAtStartup ) GUICtrlSetState ( $Checkbox_Hotkeys, $DisableHotkeys ) Else GUICtrlSetState ( $Checkbox_ShowSeconds, 4) GUICtrlSetState ( $Radio_12Hour, 1 ) GUICtrlSetState ( $Checkbox_Showdate, 4) GUICtrlSetState ( $Checkbox_Tray, 4) GUICtrlSetState ( $Checkbox_Startup, 4) GUICtrlSetState ( $Checkbox_Hotkeys, 4) IniWrite ( "StartClock.ini", "Settings", "ShowSeconds", 4 ) IniWrite ( "StartClock.ini", "Settings", "ClockType", 1 ) IniWrite ( "StartClock.ini", "Settings", "Showdate", 4 ) IniWrite ( "StartClock.ini", "Settings", "HideTrayIcon", 4 ) IniWrite ( "StartClock.ini", "Settings", "BeginAtStartup", 4 ) IniWrite ( "StartClock.ini", "Settings", "DisableHotkeys", 4 ) ReadINI() EndIf GUICtrlSetOnEvent($about_menu, "AboutPressed") GUICtrlSetOnEvent($Radio_12Hour, "ButtonPressed") GUICtrlSetOnEvent($Radio_24Hour, "ButtonPressed") GUICtrlSetOnEvent($Checkbox_ShowSeconds, "ButtonPressed") GUICtrlSetOnEvent($Checkbox_Showdate, "ButtonPressed") GUICtrlSetOnEvent($Checkbox_Tray, "ButtonPressed") GUICtrlSetOnEvent($Checkbox_Startup, "ButtonPressed") GUICtrlSetOnEvent($Checkbox_Hotkeys, "ButtonPressed") GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "ExitPressed") GuiSetOnEvent($GUI_EVENT_CLOSE, "ExitPressed") EndFunc Func AboutPressed() MsgBox(0, "About", "StartClock" & @CRLF & "Version 1.13" & @CRLF & @CRLF & "By chaos945@msn.com" & @CRLF & "Created with AutoIt v3") EndFunc Func ButtonPressed() IniWrite ( "StartClock.ini", "Settings", "ShowSeconds", GUIRead( $Checkbox_ShowSeconds ) ) IniWrite ( "StartClock.ini", "Settings", "ClockType", GUIRead( $Radio_12Hour ) ) IniWrite ( "StartClock.ini", "Settings", "Showdate", GUIRead( $Checkbox_Showdate ) ) IniWrite ( "StartClock.ini", "Settings", "HideTrayIcon", GUIRead( $Checkbox_Tray ) ) IniWrite ( "StartClock.ini", "Settings", "BeginAtStartup", GUIRead( $Checkbox_Startup ) ) IniWrite ( "StartClock.ini", "Settings", "DisableHotkeys", GUIRead( $Checkbox_Hotkeys ) ) EndFunc Func ExitPressed() GUIDelete() EndFunc Func Config() GUIDelete() MakeINI() EndFunc Func ExitScript() AdlibDisable() Opt ( "TrayIconHide", 0) Opt ("TrayIconHide", 1) Opt ("TrayIconHide", $HideTrayIcon) Exit EndFunc ;//end functions//