Jump to content


Photo

Kyokusen - Animated Clock


  • Please log in to reply
14 replies to this topic

#1 budRich

budRich
  • Members
  • 24 posts

Posted 10 August 2011 - 06:21 PM

I've made a ahk version of this:
http://www.tokyoflas...flash/kyokusen/

Posted Image

Each yellow light = 1 hour
Each red light = 5 minutes
Each green light = 1 minute

The time on the clock in the picture is: 4:54
The number means it's the nineteenth day of the month.

Download
Recommended font: FFF Galaxy

Updates:
2011-08-19
Implemented Drugwash's mod (Better tray menu, save pos, rounded corners, winmove function, hide with right-click)

This script is just a small part of a larger project.

kyokusen.ahk (requires images found in 7z file above):
/*    
# Kyokusen v0.6
# 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: 
#
# 2011-08-19 
# Drugwash's mod: 
# http://www.autohotkey.com/forum/viewtopic.php?p=465665#465665
#
# 2011-08-10
# First public release
#
# This is script is just a small part of a bigger project:
# http://www.autohotkey.com/forum/viewtopic.php?t=75528
*/


#SingleInstance force
#NoEnv 
SetBatchLines, -1
SetControlDelay, -1
SetWinDelay, -1
ListLines, Off
SetWorkingDir, %A_ScriptDir%
SendMode Input

Menu, Tray, NoStandard
Menu, Tray, Add, Hide clock, GuiContextMenu
Menu, Tray, Default, Hide clock
Menu, Tray, Add
Menu, Tray, Add, Reload, reload
Menu, Tray, Add, Exit, GuiClose

imgDir:= A_ScriptDir "\img\"
inifile := A_ScriptDir "\kyokusen.ini"
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")

Gui, Add, Text, cFFE000 BackgroundTrans Center Section x58 y0 vDate, 88
Gui, Show, % "NoActivate w100 h84 " (pos ? pos : "x20 y20"), kyokusen
WinSet, Region, 0-0 R10-10 w100 h84, kyokusen
;~ WinSet, TransColor,050505, kyokusen
Gosub, CheckTime
hCursM := DllCall("LoadCursor", "UInt", 0, "Int", 32646, "UInt")   ; IDC_SIZEALL
Return

reload:
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") " clock", % (vis ? "Show" : "Hide") " clock"
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)
}


#2 Drugwash

Drugwash
  • Members
  • 1048 posts

Posted 10 August 2011 - 07:57 PM

Funny, although hard to read. I've made a few changes for a better experience - hope you don't mind. :wink:
Due to limited OS graphic capabilities, it still doesn't show correctly on my 98SE, but I'll probably fix that at some point.

Here's the new code (uses same PNG images from the 7-zip archive above):
/*    
Kyokusen v0.5 mod
cockClock
*/


#SingleInstance force
#NoEnv 
SetBatchLines, -1
SetControlDelay, -1
SetWinDelay, -1
ListLines, Off
SetWorkingDir, %A_ScriptDir%
SendMode Input

Menu, Tray, NoStandard
Menu, Tray, Add, Hide clock, GuiContextMenu
Menu, Tray, Default, Hide clock
Menu, Tray, Add
Menu, Tray, Add, Reload, reload
Menu, Tray, Add, Exit, GuiClose

imgDir:= A_ScriptDir "\img\"
inifile := A_ScriptDir "\kyokusen.ini"
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")

Gui, Add, Text, cFFE000 BackgroundTrans Center Section x58 y0 vDate, 88
Gui, Show, % "NoActivate w100 h84 " (pos ? pos : "x20 y20"), kyokusen
WinSet, Region, 0-0 R10-10 w100 h84, kyokusen
;~ WinSet, TransColor,050505, kyokusen
Gosub, CheckTime
hCursM := DllCall("LoadCursor", "UInt", 0, "Int", 32646, "UInt")	; IDC_SIZEALL
Return

reload:
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") " clock", % (vis ? "Show" : "Hide") " clock"
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)
}


#3 budRich

budRich
  • Members
  • 24 posts

Posted 10 August 2011 - 08:17 PM

:shock: Ofcourse i don't mind. Really nice features. And you are really fast. The rounded corners gave it a great clock vibe and I will use that win dragger func alot.

There is a known issue, if you run the clock, then watch a fullscreen movie or let the screensaver start, sometimes when you go back from fullscreen the clock shows the wrong time. But always corrects itself in the next minute.

And you get used to reading it, i have used kyokusen (made with flash) as a clock in my phone for years. I think it's just as easy, even easier from long distances, to read it as a usual clock now.

#4 Drugwash

Drugwash
  • Members
  • 1048 posts

Posted 10 August 2011 - 08:41 PM

Glad you like the changes. :)
Got the 'moveit' routine in about all my scripts that involve skinned windows; it's a real asset.

I'll check that fullscreen issue when possible; right now I'm thinking of an alternative drawing method that would work on both Win9x and 2000+ systems, otherwise it'd be hard for me to fix it, since on my machine it's only showing either green or red dots, depending on the time.

The display system may be easy to learn for a young soul, but I'm an old mule, too used to the old rules. :) It's fun playing with such toys though, every once in a while. Keep bringing them to attention and have fun coding! ;)

#5 Drugwash

Drugwash
  • Members
  • 1048 posts

Posted 11 August 2011 - 11:29 AM

The MyClock script has been moved to its own topic here.

#6 jsmain

jsmain
  • Members
  • 100 posts

Posted 11 August 2011 - 11:45 AM

I am really suprised the originator went with 5 instead of 6 minutes personally.

OK, so the standard clock is based on 12-5 minute blocks. but for business, and time charging, I'd think a 10-6 minute version would be more appropriate.

Regardless, this is pretty cool.

#7 Drugwash

Drugwash
  • Members
  • 1048 posts

Posted 11 August 2011 - 12:04 PM

Imagination is the limit. Or - in my case - the lack of sleep... ;)

I wonder if those watches on the page linked to in first post, do come with a manual; I couldn't figure out any of them, except for those explicitly displaying digits. Maybe I need a Japanese brain; any offers? :p

#8 Carrozza

Carrozza
  • Members
  • 199 posts

Posted 12 August 2011 - 06:18 AM

Nice clock indeed! Really eye-catching and not hard to read.

A few suggestions come on top of my mind:
- remove the window frame and make corners just a little bit rounded;
- make it click-through;
- add adjustable transparency or - what is better - the clock becomes transparent when the mouse hover it and come back 'solid' when mouse is away.

Loving it already!
^__^

#9 budRich

budRich
  • Members
  • 24 posts

Posted 12 August 2011 - 01:22 PM

jsmain: There is a good reason. Look at the circle of red dots. Lets say the time is 3:15, that means three red dots and that lands on the dot thats on the same space a three on a regular clock would've been. Also if there where twelve dots the topdot would've been lit if the time was: 12:03 . I think it's excellent design, all cred to the original creator at Tokyo flash.

Drugwash: Your script without images is AWESOME!!! You did that in less than a day, mad skills bro. Actually this is just a small part of a big project i've been working on for some time. My plan is to release everything here on the forum the following week. Im making a presentation video right now, ill post that here to. Theres lots of stuff to improve and implement, and i hope i can get some help from the community on that. Your skills will be helpful.


Carrozza: Check out Drugwash's first post. Its a mod of the original with rounded corners and a great move function and other great features. I encourage you to follow his example, implement your functions and post your mod.
Mods: Drugwash's script deserves it's own thread, do your magic.

#10 jsmain

jsmain
  • Members
  • 100 posts

Posted 12 August 2011 - 02:03 PM

Hey, I understand for the typical clock, this is the better layout, but for time charging to a tenth of an hour, this isn't very usefull. This would be a great design for time charging with the alterations recommended.

Not trying to cut this design down. Just recommending an additional option.

#11 Drugwash

Drugwash
  • Members
  • 1048 posts

Posted 12 August 2011 - 02:14 PM

Thank you, budRich, you're too kind! :oops:
When I like something, I get completely caught in the process and won't get out of "transe" until something good comes out of that. :)

EDIT: script moved (see edited post above for link)

Can't wait for the new designs! Feel free to use anything from my script(s) and stay close to the GDI+ topic where I'm trying to find a solution for grabbing point pairs from a simple drawing, for use in WinSet, Region, the function I used in my script to create the small shapes.

#12 budRich

budRich
  • Members
  • 24 posts

Posted 13 August 2011 - 06:28 AM

jsmain: I hear you, i would've love to try the 6-min version. I'm busy whith another project right now. But its not much work to modify the script and making 10 new images. It's actually a quite fun project, making a alternative clock. And it's not impossible at all that i'll port some more of tokyo flash's watches in the future. Wouldn't it be cool, if you could change between different layouts from a Styles sub- traymenu.

OT:
How do you link to a certain post? Where can i find the postnumber? I want to link to Drugwash's mod from my post. And it's good to know.

#13 Drugwash

Drugwash
  • Members
  • 1048 posts

Posted 13 August 2011 - 06:36 AM

Hover the small file-like icon to the left of "Posted:..." string at the top of each post and right-click > Copy link. :wink:
For a topic, you must find a link that contains a &t=xxxxxx, where xxxxxx represents topic number.
Hint: topic number is in my third post, under here. ;)

But really, you shouldn't bother that much. :oops:

#14 budRich

budRich
  • Members
  • 24 posts

Posted 19 August 2011 - 03:16 PM

Updated the script.

Bugz0000 came with some great re-sizing ideas on IRC (#ahk-social (ftw)) yesterday and in the next update there will be at least 3 different sizes to choose from. Or maybe a function that re-size the images depending on the window size. But right now i'm busy completing my window manager/sidebar. So next kyokusen update might take a while. If you make any improvements or mods , please post 'em.

#15 Chimi

Chimi
  • Members
  • 4 posts

Posted 23 April 2012 - 12:04 AM

I know this is an old topic, but it looks cool and I want help.

When I run the .ahk file, with the .7z file and the .ini file in the same directory, I get the black template box thing, with the yellow number, but no images appear for numbers. Same thing happens upon compilation of the .ahk script. Any help?