Created
July 20, 2013 14:27
-
-
Save budRich/6045238 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
# Kyokusen v0.65 | |
# http://www.autohotkey.com/forum/viewtopic.php?t=75223 | |
# | |
# Made by budRich, based on a design by Tokyo Flash: | |
# http://www.tokyoflash.com/se/watch_museum/tokyoflash/kyokusen/ | |
# | |
# Updates: | |
# | |
# 2012-08-17 | |
# Small update | |
# | |
# 2011-08-19 | |
# Drugwash's mod: | |
# http://www.autohotkey.com/forum/viewtopic.php?p=465665#465665 | |
# | |
# 2011-08-10 | |
# First public release | |
*/ | |
#SingleInstance force | |
#NoEnv | |
#NoTrayIcon | |
SetBatchLines, -1 | |
SetControlDelay, -1 | |
SetWinDelay, -1 | |
ListLines, Off | |
SetWorkingDir, %A_ScriptDir% | |
SendMode Input | |
inifile := "kyokusen.ini" | |
url := "http://autohotkey.net/~HoGmasta/Kyokusen/" | |
imgDir := "img\" | |
imgDirUrl := url "src/img/" | |
fnt := "FFFGALAX.TTF" | |
msg = | |
( | |
You don't have the needed image files. `n | |
And it's not possible to download them from `n %url% | |
) | |
Menu, Tray, NoStandard | |
if ! (FileExist("img\icon.ico")) { | |
FileCreateDir, img | |
URLDownloadToFile, % imgDirUrl "icon.ico", img\icon.ico | |
if (ErrorLevel = 1) { | |
MsgBox, % msg | |
ExitApp | |
} | |
Menu, Tray, Icon, img\icon.ico | |
Menu, Tray, Icon | |
DownloadImages() | |
TrayTip | |
} | |
Menu, Tray, Add, Hide, GuiContextMenu | |
Menu, Tray, Default, Hide | |
Menu, Tray, Add | |
Menu, Tray, Add, Reload, reload | |
Menu, Tray, Add, Exit, GuiClose | |
Menu, Tray, Click, 1 | |
Menu, Tray, Icon, img\icon.ico | |
Menu, Tray, Icon | |
IniRead, pos, %inifile%, Preferences, pos, %A_Space% | |
Gui, +ToolWindow +AlwaysOnTop -Caption | |
Gui, Color, 000000 | |
Gui, Font, s6 Bold cf0f0f0, FFF Galaxy | |
Gui, Add, Picture, AltSubmit BackgroundTrans 0x4000000 vBg x3 y3 gmoveit, %imgDir%bg.png | |
GuiAddClock("h") | |
GuiAddClock("r") | |
GuiAddClock("g") | |
FormatTime, newDate,, dd | |
Gui, Add, Text, cFFE000 BackgroundTrans Center Section x58 y0 vDate, %newDate% | |
Gui, Show, % "NoActivate w100 h84 " (pos ? pos : "xcenter ycenter"), kyokusen | |
if (roundcorners) | |
WinSet, Region, 0-0 R%cornerR%-%cornerR% w100 h84, kyokusen | |
Gosub, CheckTime | |
hCursM := DllCall("LoadCursor", "UInt", 0, "Int", 32646, "UInt") ; IDC_SIZEALL | |
Return | |
DownloadImages() { | |
global imgDirUrl | |
URLDownloadToFile,% imgDirUrl "bg.png", img\bg.png | |
DownloadUnit("h") | |
DownloadUnit("r") | |
DownloadUnit("g") | |
} | |
DownloadUnit(unit) { | |
global imgDirUrl | |
cnt := ((unit == "g") ? (4) : (((unit == "h") ? (12) : (11)))) | |
i = 0 | |
Loop, %cnt% | |
{ | |
i++ | |
name:= unit i ".png" | |
TrayTip,Downloading,%name% | |
URLDownloadToFile,% imgDirUrl name, img\%name% | |
} | |
} | |
reload: | |
WinGetPos, x, y,,, kyokusen | |
IniWrite, x%x% y%y%, %inifile%, Preferences, pos | |
reload | |
GuiClose: | |
WinGetPos, x, y,,, kyokusen | |
IniWrite, x%x% y%y%, %inifile%, Preferences, pos | |
ExitApp | |
GuiContextMenu: | |
vis := !vis | |
Menu, Tray, Rename, % (vis ? "Hide" : "Show"), % (vis ? "Show" : "Hide") | |
Gui, % vis ? "Hide" : "Show" | |
return | |
moveit: | |
DllCall("SetCursor", "UInt", hCursM) | |
PostMessage, 0xA1, 2,,, A | |
return | |
GuiAddClock(unit){ | |
global | |
cnt := ((unit == "g") ? (4) : (((unit == "h") ? (12) : (11)))) | |
i = 0 | |
Loop, %cnt% | |
{ | |
i++ | |
name:= unit i | |
Gui, Add, Picture, AltSubmit BackgroundTrans Hidden v%name% x3 y3 gmoveit,% imgDir name ".png" | |
} | |
} | |
GuiHideClock(unit,cnt){ | |
global imgDir | |
i:=cnt | |
Loop, %cnt% | |
{ | |
GuiControl, Hide,% unit i | |
i-- | |
} | |
} | |
ShowClock(unit, cnt){ | |
global imgDir | |
i=0 | |
Loop, %cnt% { | |
i++ | |
GuiControl,Show,% unit i | |
Sleep, % ((unit=="g") ? (150) : (80)) | |
} | |
} | |
CheckTime: | |
SetTimer, CheckTime, Off | |
FormatTime, newMin,, mm | |
IfNotEqual, newMin, %curMin% | |
UpdateTime(newMin) | |
curMin := newMin | |
SetTimer, CheckTime, 500 | |
return | |
UpdateTime(min){ | |
global curH,curR,curG,curMin | |
chkR := UpdateG(min) | |
chkH := curH | |
IfNotEqual, chkR, %curR% | |
chkH := UpdateR(chkR) | |
curR := chkR | |
If (chkH!=curH) { | |
UpdateH(chkH) | |
FormatTime, newDate,, dd | |
GuiControl,,Date,%newDate% | |
} | |
curH := chkH | |
} | |
UpdateG(newMin){ | |
global curG | |
newR := newMin // 5 | |
newG := newMin-(newR*5) | |
GuiHideClock("g",curG) | |
curG := newG | |
IfNotEqual, newG, 0 | |
ShowClock("g", newG) | |
Return % newR | |
} | |
UpdateR(newR){ | |
global curR | |
GuiHideClock("r",curR) | |
IfNotEqual, newR, 0 | |
ShowClock("r", newR) | |
FormatTime, newH,, hh | |
Return % newH | |
} | |
UpdateH(newH){ | |
global curH | |
GuiHideClock("h",curH) | |
IfNotEqual, newH, 0 | |
ShowClock("h", newH) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment