
COMPATIBILITY: AutoHotkey 1.0.48.05 (AHK Basic)
This script is just a mixture between the no-picture GUI concept (Animated image GUI with no images...) recently presented on the board by specter333 and the TokyoFlash Kyokusen concept presented by budRich. I just added in my own vision of a 24h clock with an extra zodiac-sign touch.
The progressbar has been chosen as a last resort and it's not very visible in XP+, but looks decent in 98SE through Revolutions Pack's bitmap painting.
This is not the final version and any updates are welcome. There's an icon for the script and can be found in the package at the link below.
NOTE: The script no longer uses the free font FFF Galaxy, which has been replaced by Grixel Acme 7. It also uses the usually built-in Webdings font. I highly recommend installing the latter if not present on your system, for best display. Grixel Acme 7 by Nikos Giannakopoulos (see license in the 7-zip package) is distributed within the archive and FileInstall'ed when using the pre-built exe.
MyClock homepage
Current version: 0.0.0.5
; Topic at http://www.autohotkey.com/forum/viewtopic.php?t=75309
; Fantasy clock based on Kyokusen clock version by TokyoFlash
; http://www.tokyoflash.com/en/watch_museum/tokyoflash/kyokusen/
; Inspired from the topic posted by budRich at
; http://www.autohotkey.com/forum/viewtopic.php?t=75223
; and the script posted by specter333 at
; http://www.autohotkey.com/forum/viewtopic.php?t=75010
; This script no longer uses the [FFF Galaxy] font (see its license);
; instead, uses [Grixel Acme 7 Wide] by Nikos Giannakopoulos
; http://www.grixel.gr
; and the [Wingdings] font usually found in any Windows installation
; MyClock © Drugwash, August 2011
;**************** Directives ****************
#NoEnv
#SingleInstance, Force
SetControlDelay, -1
SetWinDelay, -1
SetBatchLines, -1
ListLines, Off
SetFormat, Float, 0.0
SetFormat, Integer, D
StringCaseSense, Off
DetectHiddenWindows, On
;*************** Identification **************
author := "Drugwash" ; author name/nickname
appname := "MyClock" ; application name
version := "0.0.0.5" ; version number
releaseD := "August 20, 2011" ; release date
releaseT := "public" ; release type (internal / public)
iconlocal := A_ScriptDir "\res\myclock.ico" ; external icon for uncompiled script
debug = %1% ; debug switch (1 = active)
;==============================
w9x := A_OSType="WIN32_WINDOWS" ? "1" : "0"
appdir := w9x ? A_ScriptDir : A_AppData "\" appname
IfNotExist, %appdir%
FileCreateDir, %appdir%
dbgdir=%appdir%\debug
inifile := appdir "\" appname "_preferences.ini"
abtwin = About %appname%
homepage := "http://www" Chr(46) "autohotkey" Chr(46) "net/~Drugwash/myclock" Chr(46) "html"
mylink := "drugwash" Chr(64) "gmail" Chr(46) "com"
ahklink := "http://www" Chr(46) "autohotkey" Chr(46) "com"
;************ Check parameters *************
if debug = source
{
debug=
srcdir=%appdir%\source
Menu, Tray, UseErrorLevel
Menu, Tray, Icon, % A_IsCompiled ? "" : iconlocal
Menu, Tray, Tip, %appname% %version% (src mode)
Menu, Tray, NoStandard
Menu, Tray, Add, About..., about
Menu, Tray, Add, Launch normally, reload
Menu, Tray, Add,
Menu, Tray, Add, View source, view
Menu, Tray, Add, Exit, cmnClose
IfNotExist, %srcdir%\res
{
IfNotExist, %srcdir%
FileCreateDir, %srcdir%
FileCreateDir, %srcdir%\res
}
FileInstall, MyClock.ahk, %srcdir%\%appname%.ahk, 1
FileInstall, func_EnumFontFamiliesEx.ahk, %srcdir%\func_EnumFontFamiliesEx.ahk, 1
FileInstall, func_GetHwnd.ahk, %srcdir%\func_GetHwnd.ahk, 1
FileInstall, MyClock_changelog.txt, %srcdir%\MyClock_changelog.txt, 1
FileInstall, res\Acme 7 Wide.ttf, %srcdir%\res\Acme 7 Wide.ttf, 1
; FileInstall, res\WINGDING.TTF, %srcdir%\res\WINGDING.TTF, 1
FileInstall, res\myclock.ico, %srcdir%\res\myclock.ico, 1
FileInstall, res\Grixel_ACME_7_readme.txt, %srcdir%\res\Grixel_ACME_7_readme.txt, 1
Msgbox, 0x43030, %appname% INFO, Source files have been saved in:`n%srcdir% !
return
view:
Run, notepad.exe %srcdir%\%appname%.ahk
return
}
else if debug
IfNotExist, %dbgdir%
FileCreateDir, %dbgdir%
;**************** Tray menu ***************
Menu, Tray, UseErrorLevel
Menu, Tray, Icon, % A_IsCompiled ? "" : iconlocal
Menu, Tray, Tip, %appname% %version%
Menu, Tray, NoStandard
Menu, Tray, Add, Hide clock, cmnContextMenu
Menu, Tray, Default, Hide clock
Menu, Tray, Add, About..., about
Menu, Tray, Add
Menu, Tray, Add, Reload, reload
Menu, Tray, Add, Exit, cmnClose
;*************** Initializations **************
IniRead, pos, %inifile%, Preferences, pos, %A_Space%
IniRead, bkg, %inifile%, Colors, colorBackgnd, 000000
IniRead, off, %inifile%, Colors, colorOff, 281414
IniRead, c0, %inifile%, Colors, color0Hour, 4F4F40
IniRead, ch, %inifile%, Colors, colorHours, FFD000
IniRead, c1, %inifile%, Colors, color1Min, 80FFFF
IniRead, c5, %inifile%, Colors, color5Min, 80FFFF
IniRead, c10, %inifile%, Colors, color10Min, FF0000
IniRead, cd, %inifile%, Colors, colorDate, 800000
IniRead, cs, %inifile%, Colors, colorSign, 800000
IniRead, cdf, %inifile%, Colors, colorDateFont, FFFFFF
IniRead, csf, %inifile%, Colors, colorSignFont, FFFFFF
IniRead, pbb, %inifile%, Colors, colorProgBkg, 000000
IniRead, pbc, %inifile%, Colors, colorProgBkg, FFFFFF
;**************** Variables ***************
; 1-Aries 2-Taurus 3-Gemini 4-Cancer 5-Leo 6-Virgo 7-Libra 8-Scorpio 9-Sagittarius 10-Capricorn 11-Aquarius 12-Pisces
zstring := "10 20 11,11 19 12,12 21 1,1 20 2,2 21 3,3 21 4,4 23 5,5 23 6,6 23 7,7 23 8,8 22 9,9 22 10"
pstring := "wx wy ww wh wc tx ty tw th fs fc fw ct tl"
string1 := "103 87 14 16 " c0 ",87 87 14 16 " ch ",71 87 14 16 " ch ",55 87 14 16 " ch ",39 87 14 16 " ch "
,23 87 14 16 " ch ",5 87 16 16 " ch ",5 71 16 14 " ch ",5 55 16 14 " ch ",5 39 16 14 " ch ",5 23 16 14 " ch "
,5 5 16 16 " ch ",23 5 30 16 " ch ",55 5 30 16 " ch ",87 5 30 16 " ch ",119 5 30 16 " ch ",151 5 16 16 " ch "
,151 23 16 14 " ch ",151 39 16 14 " ch ",151 55 16 14 " ch ",151 71 16 14 " ch ",151 87 16 16 " ch "
,135 87 14 16 " ch ",119 87 14 16 " ch
string2 := "28 24 20 35 " c10 ",52 24 20 35 " c10 ",76 24 20 35 " c10 ",100 24 20 35 " c10 ",124 24 20 35 " c10
string3 := "28 63 20 12 " c5 ",50 63 4 12 " c1 ",56 63 4 12 " c1 ",62 63 4 12 " c1 ",68 63 4 12 " c1
string4 := "76 63 44 12 " cd " 6 " cdf " 0x200,124 63 20 12 " cs " 9 " csf " 0x200"
fn35 := "Acme 7 Wide.ttf" ; file name for date font
fn36 := "WINGDING.TTF " ; file name for zodiac font
ff35 := "Grixel Acme 7 Wide" ; font face for date field
ff36 := "Wingdings" ; font face for zodiac field
dt=2 ; date loop initialization
FormatTime, st35,, dd MMM ; current date (day month)
FormatTime, d,, d ; current day
FormatTime, dm,, M ; current month
FormatTime, s,, s ; seconds initialization (for progressbar)
st36 := "^" ; zodiac sign initialization
;
Gui, 99:-Caption +ToolWindow +LastFound + AlwaysOnTop
Gui, 99:Color, %bkg%, %bkg%
Gui, 99:+Labelcmn
Gui, 99:Add, Progress, x28 y78 w116 h6 Range0-59 c%pbc% Background%pbb% Smooth vs, %s%
Gui, 99:Show, % (pos ? pos : "x100 y100") " w172 h108 NA Hide", %appname%
mwID := WinExist()
;
EFFE(fontlist, 99)
if debug
{
FileAppend, Temp=%A_Temp%\%appname%`n Fonts currently installed:`n`n%fontlist%, %A_Temp%\%appname%_fonts.txt
Run, %A_Temp%\%appname%_fonts.txt,, UseErrorLevel
}
if !InStr(fontlist, ff35 "$")
{
FileCreateDir, %A_Temp%\%appname%
FileInstall, res\Acme 7 Wide.ttf, %A_Temp%\%appname%\%fn35%
if F1 := DllCall("gdi32\AddFontResourceA", "Str", A_Temp "\" appname "\" fn35)
DllCall("SendMessage", "UInt", 0xFFFF, "UInt", 0x1D, "UInt", 0, "UInt", 0) ; WM_FONTCHANGE, HWND_BROADCAST
else MsgBox, Cannot install font %ff35%
}
if !InStr(fontlist, ff36 "$")
{
IfNotExist, %A_Temp%\%appname%
FileCreateDir, %A_Temp%\%appname%
FileInstall, res\WINGDING.TTF, %A_Temp%\%appname%\%fn36%
if F2 := DllCall("gdi32\AddFontResourceA", "Str", A_Temp "\" appname "\" fn36)
DllCall("SendMessage", "UInt", 0xFFFF, "UInt", 0x1D, "UInt", 0, "UInt", 0) ; WM_FONTCHANGE, HWND_BROADCAST
else MsgBox, Cannot install font %ff36%
}
fontlist := ""
StringSplit, t, pstring, %A_Space%
idx=0
Loop, 4
{
str := string%A_Index%
gosub builder
}
hCursM := DllCall("LoadCursor", "UInt", 0, "Int", 32646, "UInt") ; IDC_SIZEALL
Gui, 99:Show, NA
WinSet, Region, 0-0 R10-10 w172 h108, %appname%
Loop, 36
{
Gui, %A_Index%:Show, NA
Sleep, 30
}
OnMessage(0x201, "moveit")
SetTimer, altdate, 2000
SetTimer, time, 999
return
;*************** Subroutines ***************
builder:
Loop, Parse, str, CSV
{
idx++
StringSplit, v, A_LoopField, %A_Space%
i=
Loop, %v0%
{
if t%A_Index% in ff,st
{
j := t%A_Index%
%j% := v%A_Index%
continue
}
i .= t%A_Index% v%A_Index% A_Space
}
i .= "ph" mwID " ix" idx
_buildClock(i, "", st%idx%, ff%idx%)
}
return
;#######################
reload:
gosub cleanup
reload
cmnClose:
gosub cleanup
ExitApp
;#######################
cleanup:
WinGetPos, x, y,,, %appname%
IniWrite, x%x% y%y%, %inifile%, Preferences, pos
if hCursM
DllCall("DestroyCursor", "UInt", hCursM)
if F1
DllCall("gdi32\RemoveFontResourceA", "Str", A_WorkingDir "\" fn35)
if F2
DllCall("gdi32\RemoveFontResourceA", "Str", A_WorkingDir "\" fn36)
if F1|F2
DllCall("SendMessage", "UInt", 0xFFFF, "UInt", 0x1D, "UInt", 0, "UInt", 0) ; WM_FONTCHANGE, HWND_BROADCAST
return
;#######################
cmnContextMenu:
vis := !vis
Menu, Tray, Rename, % (vis ? "Hide" : "Show") " clock", % (vis ? "Show" : "Hide") " clock"
Gui, % "99:" (vis ? "Hide" : "Show")
return
;#######################
moveit:
moveit()
return
;#######################
altdate:
dt := (dt < "2" ? dt+1 : "0")
FormatTime, j,, % dt="0" ? "dddd" : (dt="1" ? "dd MMM" : "yyyy")
if !dt
StringLeft, j, j, 3
GuiControl, 35:, tv35, %j%
return
;#######################
time:
FormatTime, h,, H
FormatTime, m,, m
FormatTime, s,, s
if (d != ld)
Loop, Parse, zstring, CSV
if (dm=A_Index)
{
StringSplit, i, A_LoopField, %A_Space%
GuiControl, 36:, tv36, % Chr(93+ (d>=i2 ? i3 : i1))
break
}
if (h != lh)
Loop, Parse, string1, CSV
{
StringSplit, i, A_LoopField, %A_Space%
Gui, %A_Index%:Color, % (h<A_Index-1 ? off : i5)
}
if (m != lm)
{
Loop, Parse, string2, CSV
{
StringSplit, i, A_LoopField, %A_Space%
Gui, % (A_Index+24 ":Color"), % (m//10 < A_Index ? off : i5)
}
j := Round(10*(m/10 - m//10))
Loop, Parse, string3, CSV
{
StringSplit, i, A_LoopField, %A_Space%
if A_Index=1
Gui, 30:Color, % (j < "5" ? off : i5)
else
Gui, % (29+A_Index ":Color"), % (( j-5*(j > "4") < A_Index-1) ? off : i5)
}
}
GuiControl, 99:, s, %s%
lh := h, lm := m, ls := s
return
;#######################
about:
ownabout := A_IsCompiled ? "To obtain source code, run '" appname ".exe source'.`nCode is compatible with AHK 1.0.48.05." : "Since this is the public version,`nyou may create your own 'About' dialog.`nWould be nice if you credited the original author."
MsgBox, 0x43040, %abtwin%, %appname% %version%`tby %author%`n%releaseT% version, released %releaseD%`n`nContact: %mylink%`nAutoHotkey: %ahklink%`nHome: %homepage%`n`n%ownabout%
return
;*************** Functions *****************
moveit()
{
Global
DllCall("SetCursor", "UInt", hCursM)
PostMessage, 0xA1, 2,,, ahk_id %mwID%
}
;#################
; ix=GUI index, wc=GUI color, wx wy ww wh=GUI coords, wn=GUI name, ph=parent handle,
; st=static text, ff=font face, tx ty tw th=text coords, tl=text goto label, ct=control type
; fs=font size, fc=font color, fw=font weight
_buildClock(p, wn="", st="", ff="Tahoma")
{
Global tv1, tv2, tv3, tv4, tv5, tv6, tv7, tv8, tv9, tv10, tv11, tv12, tv13, tv14, tv15, tv16, tv17, tv18, tv19, tv20, tv21
, tv22, tv23, tv24, tv25, tv26, tv27, tv28, tv29, tv30, tv31, tv32, tv33, tv34, tv35, tv36, tv37, tv38, tv39, tv40
ix=1 ; initialize to 1 so the function wouldn't fail miserably in case there's no GUI index in parameters
Loop, Parse, p, %A_Space%
{
StringLeft, c, A_LoopField, 2
StringTrimLeft, v, A_LoopField, 2
%c% := v
}
wn := wn ? wn : "GUI" ix
Gui, %ix%:-Caption +ToolWindow +LastFound
Gui, %ix%:Margin, 0, 0
Gui, %ix%:Color, %wc%
Gui, %ix%:+Labelcmn
if st OR tl OR tw OR th OR ct
{
tl := tl ? tl : "moveit"
if ct
{
SetFormat, Integer, H
ct+=0
SetFormat, Integer, D
}
tx := tx ? tx : "0"
ty := ty ? ty : "0"
tw := tw ? tw : ww
th := th ? th : wh
Gui, %ix%:Font, s%fs% c%fc% %fw%, %ff%
if ct=0x10E
Gui, %ix%:Add, Picture, x%tx% y%ty% w%tw% h%th% %ct% Center BackgroundTrans vtv%ix% g%tl%,%st%
else
Gui, %ix%:Add, Text, x%tx% y%ty% w%tw% h%th% %ct% Center BackgroundTrans vtv%ix% g%tl%,%st%
}
g%ix%ID := WinExist()
Gui, %ix%:Show, x%wx% y%wy% w%ww% h%wh% NA Hide, %wn%
if ix = 7
WinSet, Region, 0-15 8-0 15-15 0-15, GUI7
if ix = 12
WinSet, Region, 0-0 15-8 0-15 0-0, GUI12
if ix = 17
WinSet, Region, 15-0 8-15 0-0 15-0, GUI17
if ix = 22
WinSet, Region, 15-15 0-8 15-0 15-15, GUI22
if ph
DllCall("SetParent", "UInt", g%ix%ID, "UInt", ph)
}
#include func_EnumFontFamiliesEx.ahk
func_EnumFontFamiliesEx script:; © Drugwash 2010-2011
; returns a list of all font families installed on the current system
; font face (name) $ font style $ charset | (colon separator)
;———————————————————————————————
EFFE(ByRef fontlist, gid="1", p="C1")
{
if !(hwndOwner := GetHwnd(gid))
return
if !p
p=C1
VarSetCapacity(LogFont, 60, 0)
Loop, Parse, p, %A_Space%
{
StringLeft, i, A_LoopField, 1
StringTrimLeft, j, A_LoopField, 1
if i=C
NumPut(j, LogFont, 23, "UChar") ; DEFAULT_CHARSET
if i=F
DllCall("lstrcpy", "UInt", &LogFont+28, "UInt", &j)
}
VarSetCapacity(lParam, 8196, 0)
hDC := DllCall("GetDC", UInt, hwndOwner)
CBF := RegisterCallback("EFFECBFunc")
r := DllCall("EnumFontFamiliesExA", "UInt", hDC, "UInt", &LogFont, "UInt", CBF, "UInt", &lParam, "UInt", 0)
VarSetCapacity(lParam, -1)
StringTrimRight, fontlist, lParam, 1
Sort, fontlist, CL D| U
return fontlist ? 1 : 0
}
;———————————————————————————————
EFFECBFunc(elfe, ntme, ft, lP)
{
Static list
VarSetCapacity(fn, 32, 0)
DllCall("lstrcpy", "UInt", &fn, "UInt", elfe+28)
VarSetCapacity(fn, -1)
fst=P
fst .= NumGet(elfe+0, 16, "Int") > 400 ? "B" : ""
fst .= NumGet(elfe+0, 20, "UChar") ? "I" : ""
fst .= NumGet(elfe+0, 21, "UChar") ? "U" : ""
fst .= NumGet(elfe+0, 22, "UChar") ? "S" : ""
cs := NumGet(elfe+0, 23, "UChar")
if (fn <> "")
IfNotInString, list, %fn%$
list .= fn "$" fst "$" cs "|"
DllCall("lstrcpy", "UInt", lP, "UInt", &list)
return (fn <> "")
}
#include func_GetHwnd.ahk
func_GetHwnd script:GetHwnd(gid="1")
{
i := A_Gui
old := A_DetectHiddenWindows
ofi := A_FormatInteger
SetFormat, Integer, D
DetectHiddenWindows, on
gid := gid ? gid : 1
if gid is not number
hwnd := WinExist(gid)
else if gid < 1
hwnd := 0
else if gid between 1 and 99
{
gid+=0
Gui, %gid%:+LastFoundExist
WinGet, hwnd, ID
if i
Gui, %i%:+LastFound
}
else hwnd := gid
DetectHiddenWindows, %old%
SetFormat, Integer, Hex
hwnd+=0
SetFormat, Integer, %ofi%
return hwnd
}




