Jump to content

Start Button Clock


 Share

Recommended Posts

Someone requested this and I thought you wanted to see this too.

It displays the current time on the start button.

I tested this only on Windows XP Pro NL. So, I can't guarantee anything.

To exit the script you can use the hotkey: CTRL+ALT+X

Here it is:

AutoItSetOption("WinTitleMatchMode", 4)

Global $ExitScript
HotKeySet("^!x", "ExitScript");CTRL+ALT+X

For $i = 0 To 43200
If @HOUR <= 11 Then
   $Hour = @HOUR
ElseIf @HOUR > 12 Then
   $Hour = String(@HOUR - 12)
ElseIf @HOUR = 12 Then
   $Hour = String(@HOUR)
ElseIf @HOUR = 00 Then
   $Hour = "12"
EndIf

$Time = $Hour & ":" & @MIN

ControlSetText("classname=Shell_TrayWnd", "", "Button1", $Time)
Sleep(30 * 1000)
Next

Func ExitScript()
Exit
EndFunc

Exit
Link to comment
Share on other sites

Thanks for sharing!

Now if we could only change the Start button tooltip from "click here to begin" to the current date.... I know it's hard coded into explorer.exe, but I've seen related tweaks that let you rename start menu entries (Programs/Search/Run/etc.) by setting a locale registry keys.... If I can only find those tweaks again.

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

AutoItSetOption("WinTitleMatchMode", 4)

Global $ExitScript
HotKeySet("^!x", "ExitScript");CTRL+ALT+X

For $i = 0 To 43200
ControlSetText("classname=Shell_TrayWnd", "", "Button1", ControlGetTextclassname=Shell_TrayWnd", "", "TrayClockWClass1"))
Sleep(30 * 1000)
Next

Func ExitScript()
Exit
EndFunc

Exit

Edit: Now this code should work, however it really isn't a great idea after all... :D

BTW, yes you can modify the start button with reshack, but I'm not sure how you would change the tooltip to the current date.

K

Edited by lte5000
Link to comment
Share on other sites

Your script doesn't work.

I found the location where the tooltip is.

If you open explorer.exe using Resource Hacker.

- unfold String Table

- unfold 'subfolder' 34

- click on 1043

In the rightpane you see "click here to begin".

I don't think we can do anything because that line is hardcoded (static).

And if you want the tooltip to change every day, you'll have to make it dynamic.

Link to comment
Share on other sites

I made progress. First the problem was: I didn't know how to make the clock fit in the start button.

So I left the seconds and AM/PM out.

But I couldn't help myself to find away to resize the startbutton.

So, I found a away. Then came another problem: the start button was overlapping the taskswitch.

So I resized (moved) both and the seconds fit in.

Here's the script (Windows XP only):

AutoItSetOption("WinTitleMatchMode", 4)

Global $ExitScript
HotKeySet("^!x", "ExitScript");CTRL+ALT+X

ControlMove("classname=Shell_TrayWnd", "", "Button1", -1, -1, 135)  ; Windows XP Luna Theme
ControlMove("classname=Shell_TrayWnd", "", "ToolbarWindow322", 35, -1); Windows XP Luna Theme

;ControlMove("classname=Shell_TrayWnd", "", "Button1", -1, -1, 75)   ; Windows Classic Theme
;ControlMove("classname=Shell_TrayWnd", "", "ToolbarWindow322", 20, -1); Windows Classic Theme

For $i = 0 To 43200
If @HOUR <= 11 Then
  $Hour = @HOUR
ElseIf @HOUR > 12 Then
  $Hour = String(@HOUR - 12)
ElseIf @HOUR = 12 Then
  $Hour = String(@HOUR)
ElseIf @HOUR = 00 Then
  $Hour = "12"
EndIf

$Time = $Hour & ":" & @MIN & ":" & @SEC

ControlSetText("classname=Shell_TrayWnd", "", "Button1", $Time)
Sleep(1000)
Next

Func ExitScript()
Exit
EndFunc

Exit
Edited by SlimShady
Link to comment
Share on other sites

no, my theme is MCE (Media Center Edition) Theme...u probably dont have that unless u have a MCE, but if i change the word "Luna" in your code, will that fix it or is it more than that?

-Brett
Link to comment
Share on other sites

ControlMove("classname=Shell_TrayWnd", "", "Button1", -1, -1, 122 ) ; Windows Classic Theme

...for xp mce....

but what does the second control move of the set do? i change it or leave it the same but it doesn't do anything

-Brett
Link to comment
Share on other sites

I found the location where the tooltip is.

If you open explorer.exe using Resource Hacker.

- unfold String Table

- unfold 'subfolder' 34

- click on 1043

In the rightpane you see "click here to begin".

I don't think we can do anything because that line is hardcoded (static).

And if you want the tooltip to change every day, you'll have to make it dynamic.

Exactly. That's why I mentioned the locale things. "Programs", "Settings", "Search", "Run..." are also hard-coded in explorer.exe, but registry keys can change the display names. If lucky, we could write to a registry key that controls the tooltip message (and hope that the tooltip reads the registry key each time it is called. I haven't found the keys yet, and I forget if you need to restart explorer.exe for the changes to take effect.

Edit: Well, I found out how to change the names of some start menu entries. However, the tweak does not work if you use the classic start menu instead of xp's start panel; and I did not find any registry key for changing the start button tooltip.

See http://www.kellys-korner-xp.com/xp_tweaks.htm tweaks #151-152 for more info.

Oh well. I still like the time on the start button script :D

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Creates a new Start Button ToolTip with the current date. Sort of buggy, and I don't feel inclined to make it work better right now.:D Only tested on Win98SE.

Known bugs:

If someone is interested, I think one poblem is: ("MouseCoordMode", 0) -- Because of this it will only draw the tooltip if the TaskBar is the active window.

But I'm not sure how to change it to work with ("MouseCoordMode", 1).

AutoItSetOption("WinTitleMatchMode", 4)
AutoItSetOption("MouseCoordMode", 0)
$startPos=ControlGetPos("classname=Shell_TrayWnd", "", "Button1")

While 1
$mousePos=MouseGetPos()

If $mousePos[0] >= $startPos[0] AND $mousePos[0] <= $startPos[2] AND $mousePos[1] >= $startPos[1] AND $mousePos[1] <= $startPos[3] Then 
ToolTip(@TAB & @MDAY & "/" & @MON & "/" & @YEAR & @CR & "      Customized with AutoIt   ", $mousePos[0] , 565)
Do 
$mousePos=MouseGetPos()
Sleep(60)
Until $mousePos[0] <> $startPos[0] AND $mousePos[0] > $startPos[2]  AND $mousePos[1] <> $startPos[1] AND $mousePos[1] > $startPos[3]
ToolTip("")
EndIf
    
Sleep(60) 
WEnd

Have a great day.

K

Edited by lte5000
Link to comment
Share on other sites

  • 2 weeks later...

Sweet work guys, I found this thread looking for ways to add the date to the current "click here to begin" tooltip!

If I figure out an easy way to rename/remove/replace the current tooltip I'll post here.

SlimShady: I've been working on the script, checkout my revisions. I put up a webpage to display my progress.

Graciously hosted by OSNN.net

Note: The script now runs using a INI for configuration you can get it from the website if you want to use the configuration options.

$DisableTrayIcon = IniRead ( "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" )

; Controls system startup procedures
If IniRead ( "StartClock.ini", "Settings", "RunAtStartUp", "0" ) = 1 Then
 RegWrite ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "StartClock", "REG_SZ", @ScriptFullPath )
EndIf
If IniRead ( "StartClock.ini", "Settings", "RunAtStartUp", "0" ) = 0 Then
 RegDelete ( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "StartClock" )
EndIf

HotKeySet( "^!x", "ExitScript" ); CTRL+ALT+X
HotKeySet( "^!d", "ShowDate" ); CTRL+ALT+D

;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 ( "StartClock.ini", "Settings", "24HourClock", "0" )
$12HourClock_WithSeconds = IniRead ( "StartClock.ini", "Settings", "12HourClock_WithSeconds", "0" )
$Refresh_Rate = IniRead ( "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 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
Edited by chaos945
Link to comment
Share on other sites

  • 10 months later...

I made progress. First the problem was: I didn't know how to make the clock fit in the start button.

So I left the seconds and AM/PM out.

But I couldn't help myself to find away to resize the startbutton.

So, I found a away. Then came another problem: the start button was overlapping the taskswitch.

So I resized (moved) both and the seconds fit in.

I had a little problem with the QuickLaunch bar so I made some changes:

; Resize Start Button

ControlMove("classname=Shell_TrayWnd", "", "Button1", -1, -1, 123) ; Windows XP Luna Theme

; Resize QuickLaunch

ControlMove("classname=Shell_TrayWnd", "", "ToolbarWindow323", 20, -1); Windows XP Luna Theme

; Resize TaskBar

ControlMove("classname=Shell_TrayWnd", "", "ToolbarWindow322", 35, -1); Windows XP Luna Theme

Link to comment
Share on other sites

wait so is there a way to do this with mce/royale because i can't get it to work

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...