In Windows XP (maybe in other Windows versions, too) there is a small analog clock in the Date and Time settings window. We can cut it off and position anywhere on screen, and make it semi transparent. We got an analog clock always on top, no external file is needed, but we are stuck with fixed size, and shape and color like the moon.
With left dragging you can move the clock to a place you like, it will stay there. With editing the assignments to wX and wY you can choose the initial position of the clock. If you make the (thick enough) Taskbar its parent, you can keep it in there, maybe on top of the digital clock in the Tray. With the right transparency you can see both.
A double click on the clock toggles it between full window or just the clock face. In full window mode you can set the time, the time zone or let the PC synchronize to an Internet time server. If you close this window (also by clicking on OK or Cancel), the script exits. Click on Apply after changing time, to keep the clock open. Exitting the script also closes the clock.
Code:
#NoEnv
SetBatchLines -1
CoordMode Mouse, Screen
OnExit Exit
Run rundll32.exe shell32.dll`,Control_RunDLL timedate.cpl`,`,0,,,PID
GroupAdd Group1, ahk_pid %PID% ; Work around forbidden variables in #IfWinActive
WinWait ahk_pid %PID%
WinSet AlwaysOnTop, ON, ahk_pid %PID%
WinGetPos wX0, wY0,,, ahk_pid %PID% ; Default position of Date/Time settings
ControlGetPos cX,cY,cW,cH, ClockWndMain1, ahk_pid %PID%
oX := cX + cW//2 ; Origin = center of clock
oY := cY + cH//2 - 1 ; -1/-2 <-- Windows Theme
dX := 0.75 * 150 ; Zoom factor * Diameter in x direction
dY := dx*A_ScreenHeight/A_ScreenWidth*4/3 ; Handle clock distortion, y-diameter
XY := Round(oX-dX/2) "-" Round(oY-dY/2) ; Position of clock within control
wX := A_ScreenWidth//2 - oX
wY := -Round(oY-dY/2) ; Initial clock position
Full := Pos(0) ; Show cut-off clock
SetTimer IsClosed, 999 ; Exit script if clock is closed
#IfWinActive ahk_group Group1 ; Group1 = Date/Time settings, in any language
~LButton:: ; Double click toggles clock - full Date/Time window
If (A_PriorHotKey = "~LButton Up" and A_TimeSincePriorHotkey < 500)
Full := Pos(!Full)
Else If !Full { ; Start left-drag
MouseGetPos mX0, mY0 ; Mouse position at start of drag
SetTimer Drag, 100
}
Return ; OK-Cancel: close clock! Click on Apply for changes
~LButton Up::SetTimer Drag, OFF
Drag: ; Left-drag
MouseGetPos mX, mY
wX += mX-mX0 ; change window position
wY += mY-mY0
WinMove ahk_pid %PID%,, %wX%, %wY%
mX0 = %mX% ; remember new mouse position
mY0 = %mY%
Return
Pos(Full) { ; Full Date/Time window, or cut-off Clock
Global PID, wX, wY, wX0, wY0, XY, dX, dY
If Full { ; Full window at default position
WinSet Region,,ahk_pid %PID%
WinSet Transparent, Off, ahk_pid %PID%
WinMove ahk_pid %PID%,, %wX0%, %wY0%
} Else { ; Clock at last position
WinSet Region, %XY% w%dX% h%dY% E, ahk_pid %PID%
WinSet Transparent, 200, ahk_pid %PID%
WinMove ahk_pid %PID%,, %wX%, %wY%
}
Return Full
}
IsClosed: ; Check if Clock is closed
IfWinExist ahk_pid %PID%
Return
Exit: ; Close clock at Exit script
WinClose ahk_pid %PID%
ExitApp
Edit 20060810: Changes:
- Instead of control.exe, rundll32 is used (with shell32.dll) to start the date/time settings. This way there is no need for the window title, so the clock in a non-English Windows should work, too. The process ID is returned by the Run command, which is enough to identify the clock.
- The position of the clock within its window is not directly determined by constants, but first the clock-control position is inquired and constant offsets are only used within this control. Hopefully the position computed this way does not depend on system settings, like fonts, title bar width, etc.
- The full date/time settings window appear in its Windows default position, not centered (which would require to get the monitor working area and do some math).
Edit 20060810.1: Removed title reference from #IfWinActive directive
Edit 20060810.2: Changes:
- Guess clock size from the size of its control
- Allow setting a zoom factor (0.75)
Edit 20060810.3: Using screen size for aspect ratio (thanks to holomind)
Here is a simple variant for Vista.

Code:
W:=H:=124, gL:=3, gT:=22 ; Clock Width,Height and Gaps (Left,Top)
#SingleInstance Force
#NoEnv
#Persistent
SetWinDelay -1
CoordMode Mouse, Screen ; for moving the clock window
OnExit Exit
Menu Tray, NoStandard ; Short tray menu:
Menu Tray, Add, Move, Move ; Move the clock with the mouse
Menu Tray, Add, Exit, Exit
Menu Tray, Icon, %A_WinDir%\system32\SHELL32.dll,266
WinGet ID, ID, A ; ID of active window
Run rundll32.exe shell32`,Control_RunDLL timedate.cpl`,`,0,,,PID
WinWait ahk_pid %PID%
WinSet AlwaysOnTop, ON, ahk_pid %PID%
WinGetPos wX0, wY0,,, ahk_pid %PID% ; Default position of Date/Time settings
ControlGetPos cX,cY,cW,cH, ClockWndMain1, ahk_pid %PID%
wX := gL - cX, wY := gT - cY ; Initial clock position: Top left of screen
oX := W//2 - wX, oY := H//2 - wY ; Origin = center of clock
Rg := -wX . "-" . -wY . " E w"W " h" H ; Shape of clock (Region)
SetTimer Status ; Activate | Exit script if clock is closed
WinActivate ahk_id %ID% ; Activate original window
Status: ; Check if Clock is active | closed
IfWinNotExist ahk_pid %PID% ; Clock shown when "Date and Time Settings" is inactive
ExitApp
If WinActive("ahk_pid " PID) {
If(Full = 0) ; Make Full window
Full := Pos("","","+0x800000","","Off",wX0,wY0,PID)
}
Else
If(Full = "") ; Truncate window, click-through (Initial case)
Full := Pos(0,Rg,"-0x800000","0x20",200,wX,wY,PID)
Return
Move:
mX0 := wX+oX, mY0 := wY+oY ; remember starting mouse position
MouseMove mX0, mY0, 10 ; move cursor to center of clock
SetTimer Drag, 10 ; start dragging
HotKey LButton, Stop, On ; Click: stop
Return
Drag:
MouseGetPos mX, mY ; current cursor position
wX += mX-mX0, wY += mY-mY0 ; new clock position
WinMove ahk_pid %PID%,, %wX%, %wY%
mX0 := mX, mY0 := mY ; remember cursor
Return
Stop: ; Stop dragging
SetTimer Drag, Off
HotKey LButton,Off
Return
Exit: ; Close clock at Exit script
WinClose ahk_pid %PID%
ExitApp
Pos(P,R,S,E,T,X,Y,PID) { ; Set the clock window full or truncated
WinSet Region, %R%, ahk_pid %PID%
WinSet Style, %S%, ahk_pid %PID%
WinSet ExStyle,%E%, ahk_pid %PID%
WinSet Transparent, %T%, ahk_pid %PID%
WinMove ahk_pid %PID%,, %X%, %Y%
Return P
}
It is somewhat different: The clock is semi-transparent, always on top and click-through, that is, mouse clicks activate controls beneath the clock. This way you don’t have to move it that often.
The top line contains the metrics of the clock, which might change with a different theme or personalization of Windows. Only these numbers need to be tuned to non-standard settings.
If you start the date/time settings applet of Windows (e.g. from the tray) or click the taskbar icon, the moon clock will turn into the standard data/time settings, staying on the top. If you make another window active, the clock gets back to its small form and jumps back to its previous position.
The tray menu of the script contains “move”. If you select it, the mouse cursor moves to the center of the clock, and the clock would follow the cursor to a new location. A mouse click pins the clock to its new location.
If you want to download, the same script is also
here. Just copy it to somewhere an run.