Sign in to follow this  
Followers 0
Chimp

ascii art clock

13 posts in this topic




Now can you make one that's round. Only joking (unless of course you want to :D). Very nice idea.

Share this post


Link to post
Share on other sites

Very cool compact code :thumbsup:

I added $WS_EX_COMPOSITED and the GUI doesn't flicker anymore on my Win8.1 notebook.

What bothers me is that AM / PM moves on each second.

 

 

 


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
5 hours ago, czardas said:

Now can you make one that's round. Only joking (unless of course you want to :D). Very nice idea.

thanks czardas, .... a round ascii clock? ...

4 hours ago, UEZ said:

Very cool compact code :thumbsup:

I added $WS_EX_COMPOSITED and the GUI doesn't flicker anymore on my Win8.1 notebook.

What bothers me is that AM / PM moves on each second.

thanks UEZ,  $WS_EX_COMPOSITED... interesting extended Style.
Fixed the am/pm (it doesn't bothers any more....). updated first post.

 

Thanks to all those who have clicked "like this" :P


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Definitely a cool little project. 

Share this post


Link to post
Share on other sites
2 hours ago, Chimp said:

thanks czardas, .... a round ascii clock? ...

thanks UEZ,  $WS_EX_COMPOSITED... interesting extended Style.
Fixed the am/pm (it doesn't bothers any more....). updated first post.

 

Thanks to all those who have clicked "like this" :P

:thumbsup:


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

I guess if you used a really small font you could do an almost round ascii clock. :idea:

Share this post


Link to post
Share on other sites

I assume czardas means something like this here: http://codegolf.stackexchange.com/questions/10759/build-an-analog-clock 

1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

A practical problem is how to freely position individual ascii chars on label (using monospaced font as courier new) at a given row and a given column leaving unchanged what is already printed on the label.
for example it would be useful a functio like Print($hLabel, $sChar, $iCol, $iRow)


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Here a version for a ASCII Analogue Clock - (GDI+ free version :sweating:):

;coded by UEZ build 2016-02-23
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global Const $iWm = 29, $iHm = 19, $imX = Ceiling($iWm / 2), $imY = Ceiling($iHm / 2), $fRad = ACos(-1) / 180
Global $aArrayMatrix[$iHm + 1][$iWm + 1], $aPic[$iHm], $i, $f = $iHm

Global Const $iW = Ceiling($iWm * $f * 2 / 3) - $iWm / 2, $iH = $iHm * $f, $iW2 = $iW / 2
Global Const $hGUI = GUICreate("ASCII Analogue Clock by UEZ v1.1", $iW, $iH, -1, -1, -1, $WS_EX_COMPOSITED)

For $i = 0 To $iHm - 1
    $aPic[$i] = GUICtrlCreateLabel("", 0, $i * $f, $iW, $f)
    GUICtrlSetFont(-1, $f * 0.825, 800, 0, "Courier new", 5)
    GUICtrlSetBkColor(-1, Sin($i * $iHm / 0x150) * 0x100 + 0xFF00)
    GUICtrlSetColor(-1, 0x0)
Next
GUISetState()

AnimClock()

GUIRegisterMsg($WM_TIMER, "AnimClock")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", 1000, "int", 0)


Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIRegisterMsg($WM_TIMER, "")
            GUIDelete()
            Exit
    EndSwitch
Until False

Func AnimClock()
    Local $i, $iX, $iY, $sx, $imm = $iWm, $sBg = " "
    Local $aSlope_Hr = CalcSlope(   $imY,   $imX,   $imY + Cos((-90 + 30 * (Mod(@HOUR, 12) + @MIN / 60)) * $fRad) * $imX * 0.45, $imX + Sin((-90 + 30 * (Mod(@HOUR, 12) + @MIN / 60)) * $fRad) * $imY * 0.45)
    Local $aSlope_Min = CalcSlope(  $imY,   $imX,   $imY + Cos((-90 + 6 * @MIN) * $fRad) * $imX * 0.65,                         $imX + Sin((-90 + 6 * @MIN) * $fRad) * $imY * 0.65)
    Local $aSlope_Sec = CalcSlope(  $imY,   $imX,   $imY + Cos((-90 + 6 * @SEC) * $fRad) * $imX * 0.85,                         $imX + Sin((-90 + 6 * @SEC) * $fRad) * $imY * 0.85)
    Local $aSlope_Sec2 = CalcSlope( $imY,   $imX,   $imY + Cos((-270 + 6 * @SEC) * $fRad) * $imX * 0.35,                        $imX + Sin((-270 + 6 * @SEC) * $fRad) * $imY * 0.35)
    Local Const $fSy_hr = $aSlope_Hr[0] / $imm
    Local Const $fSx_hr = $aSlope_Hr[1] / $imm
    Local Const $fSy_min = $aSlope_Min[0] / $imm
    Local Const $fSx_min = $aSlope_Min[1] / $imm
    Local Const $fSy_sec = $aSlope_Sec[0] / $imm
    Local Const $fSx_sec = $aSlope_Sec[1] / $imm
    Local Const $fSy_sec2 = $aSlope_Sec2[0] / $imm
    Local Const $fSx_sec2 = $aSlope_Sec2[1] / $imm
    For $i = $imm To 0 Step - 1
        $aArrayMatrix[$imY - 1 + Round($i * $fSy_min)][$imX - 1 + Round($i * $fSx_min)] = ChrW(9618)
        $aArrayMatrix[$imY - 1 + Round($i * $fSy_hr) ][$imX - 1 + Round($i * $fSx_hr)] = ChrW(9617)
    Next
    For $i = $imm To 0 Step - 1 ;write seconds to the top
        $aArrayMatrix[$imY - 1 + Round($i * $fSy_sec)][$imX - 1 + Round($i * $fSx_sec)] = ChrW(9619)
        $aArrayMatrix[$imY - 1 + Round($i * $fSy_sec2)][$imX - 1 + Round($i * $fSx_sec2)] = ChrW(9619)
    Next
    $aArrayMatrix[$iHm - 1][0] = "U"
    $aArrayMatrix[$iHm - 1][1] = "E"
    $aArrayMatrix[$iHm - 1][2] = "Z"
    $aArrayMatrix[$iHm - 1][3] = ChrW(9786)
    $aArrayMatrix[$imY + 4][$imX - 1] = @HOUR > -1 And @HOUR < 12 ? "A" : "P"
    $aArrayMatrix[$imY + 4][$imX] = "M"
    For $i = 0 To 360 Step 30
        $aArrayMatrix[$imY - 1 + Round(Cos($i * $fRad) * $imY * 0.92)][$imX - 1 + Round(Sin($i * $fRad) * $imX * 0.92)] = "."
    Next
    For $iY = 0 To $iHm - 1
        $sx = ""
        For $iX = 0 To $iWm - 1
            $t = $aArrayMatrix[$iY][$iX]
            $t = ($t = "") ? $sBg : $t
            Switch $iX
                Case 0
                    Switch $iY
                        Case $imY - 1
                            $t = "9"
                    EndSwitch
                Case $iWm - 1
                    Switch $iY
                        Case $imY - 1
                            $t = "3"
                    EndSwitch
                Case $imX - 1
                    Switch $iY
                        Case 0
                            $t = "12"
                        Case $iHm - 1
                            $t = "6"
                        Case $iMy - 1
                            $t = ChrW(8986)
                    EndSwitch
            EndSwitch
            $sx &= $t
            $aArrayMatrix[$iY][$iX] = $sBg
        Next
        GUICtrlSetData($aPic[$iY], $sx)
    Next
EndFunc

Func CalcSlope($iX1, $iY1, $iX2, $iY2)
    Local $aSlope[2] = [$iY2 - $iY1, $iX2 - $iX1]
    Return $aSlope
EndFunc

 

Edited by UEZ
added v1.1
2 people like this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
4 hours ago, UEZ said:

Here a version for a ASCII Analogue Clock - (GDI+ free version :sweating:):

.....

Hi UEZ, nice version !.

you used a matrix of labels as chars container to build and position clock hands in fixed position... interesting solution.
(as you can see is harder using simple ascii chars than GDI+... :))

Nice analog Clock BTW :thumbsup:


I approched the problem in a different way, I used just one big label as a blackboard where i can write at any location using the PrePrint() / Print() functions that allows me to specifing the wanted horizontal and vertical locations where to print chars or strings as well. Down here there is my experimental version:

On 20/2/2016 at 9:48 PM, czardas said:

I guess if you used a really small font you could do an almost round ascii clock. :idea:

... here we go... :)

 

#include <GUIConstants.au3>
HotKeySet("{ESC}", "EndOfTime")
Global $sBuffer = _StringReplicate(" ", 80) & @CRLF ; a string of 80 blank spaces + @crlf
$sBuffer = _StringReplicate($sBuffer, 24) ; 25 of above lines

Global $MyGui = GUICreate("", 400, 300, -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE, $WS_EX_COMPOSITED, $WS_EX_LAYERED))
Global $hClock = GUICtrlCreateLabel("", 0, 0, 400, 400, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetFont(-1, 7, 0, 0, "Courier new")
GUICtrlSetData($hClock, $sBuffer)
GUISetState()

;          X,  Y, Ray, Char, Step
TextCircle(40, 13, 12, "", 12) ; draw Hours on clock
TextCircle(40, 13, 11, ".", 60) ; draw Mins on clock
PrePrint("O", 40, 13) ; center of the clock
While 1
    $iHour = @HOUR
    $iMin = @MIN
    $iSec = @SEC
    For $ii = 1 To 7 ; draw clock hands
        TextPosOnCircle(40, 13, 8 - $ii, 'H', 12, $iHour) ; 1 houur
        TextPosOnCircle(40, 13, 9 - $ii, 'm', 60, $iMin) ; 1 min
        TextPosOnCircle(40, 13, 10 - $ii, '.', 60, $iSec) ; 1 min
    Next
    PrePrint($iHour & ":" & $iMin & ":" & $iSec, 36, 19)
    Print(); show whole buffer on the label
    Sleep(1000)
    For $ii = 1 To 7 ; erase clock hands
        TextPosOnCircle(40, 13, 8 - $ii, ' ', 12, $iHour) ; 1 houur
        TextPosOnCircle(40, 13, 9 - $ii, ' ', 60, $iMin) ; 1 min
        TextPosOnCircle(40, 13, 10 - $ii, ' ', 60, $iSec) ; 1 min
    Next
WEnd

; From HtabVtab (1 based) to Absolute
; -----------------------------------
Func GetAbsPos($iHtab = 1, $iVtab = 1, $iScreenWidth = 80)
    Return ($iVtab - 1) * ($iScreenWidth + 2) + $iHtab ; position within the String buffer
EndFunc   ;==>GetAbsPos

Func PrePrint($sString = "", $iHtab = 1, $iVtab = 1) ; Print to String Buffer only
    $sBuffer = StringReplace($sBuffer, GetAbsPos($iHtab, $iVtab), $sString)
EndFunc   ;==>PrePrint

Func Print() ; Copy String Buffer to Label
    GUICtrlSetData($hClock, $sBuffer)
EndFunc   ;==>Print

; returns one or more chars replicated n times
; Example: ConsoleWrite(_StringReplicate('*', 5) & @CRLF)
Func _StringReplicate($sChars = "", $iRepeats = 0)
    $sChars = String($sChars)
    $iRepeats = Int(Abs(Number($iRepeats)))
    Return StringReplace(StringFormat('%' & $iRepeats & 's', ""), " ", $sChars)
EndFunc   ;==>_StringReplicate

; Drawing a circle using SIN and COS
Func TextCircle($cx = 40, $cy = 12, $r = 12, $sChar = "", $iStep = 12)
    Local $pi = 3.14159, $nr = 0
    For $i = 1.56 To (2 * $pi) + 1.56 Step ($pi * 2) / $iStep
        $x = Cos($i) * $r * 3 ; compensate horizontally
        $y = Sin($i) * $r
        PrePrint(($sChar = "" ? $nr : $sChar), Int($cx - $x), Int($cy - $y))
        $nr += 1
    Next
    Print()
EndFunc   ;==>TextCircle

; position a char along a circle to a wanted point
Func TextPosOnCircle($cx, $cy, $r, $sChar, $iStep, $iValue)
    Local $pi = 3.14159
    Local $iStepper = (($pi * 2) / $iStep)
    $i = 1.56 + ((($iValue + 1) * $iStepper) - $iStepper)
    $x = Cos($i) * $r * 3 ; compensate harizontal
    $y = Sin($i) * $r
    PrePrint($sChar, Int($cx - $x), Int($cy - $y))
    ; Print()
EndFunc   ;==>TextPosOnCircle

Func EndOfTime()
    If WinActive("[ACTIVE]") = $MyGui Then Exit
EndFunc   ;==>EndOfTime

 

2 people like this

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

17 hours ago, Chimp said:

Hi UEZ, nice version !.

you used a matrix of labels as chars container to build and position clock hands in fixed position... interesting solution.
(as you can see is harder using simple ascii chars than GDI+... :))

Nice analog Clock BTW :thumbsup:


I approched the problem in a different way, I used just one big label as a blackboard where i can write at any location using the PrePrint() / Print() functions that allows me to specifing the wanted horizontal and vertical locations where to print chars or strings as well. Down here there is my experimental version:

... here we go... :)

 

 

 

Well, I used a 2D array which is similar to a graphic canvas where you have width and height and calculated the "line" from the center to the appropriate position. My first idea was to draw the clock first to GDI+ and transform afterwards the bitmap to ASCII chars but it was too complicated.

Many ways lead to Rome and probably your way is much shorter than my way. ;)

Your version looks much better. :thumbsup:

 

Edit: updated my version to v1.1 (see #10)

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • Chimp
      By Chimp
      A simple endless kaleidoscope made  on a RichEdit control (hit esc to exit)
      Idea is from this link: http://www.calormen.com/jsbasic/ select the "Rod's Color Pattern" demo and run it on the Apple 2 emulator on that web page to see the original Apple II version.
      ; Idea from this link: http://www.calormen.com/jsbasic/ ; get the "Rod's Color Pattern" from the "Select a sample..." combo and run it ; #include <GuiRichEdit.au3> #include <GUIConstants.au3> HotKeySet("{ESC}", "_TheEnd") ; Global $iHwidth = 40, $iVheight = 40; width and height of screen Global $sBuffer = _StringReplay(_StringReplay(" ", $iHwidth + 1) & @CRLF, $iVheight) ;to fill the RichEdit Global $sChar = " " Global Const $aApplesoft_color[16] = [ _ ; LoRes colors in Applesoft basic 0x000000, _ ; 0x0 = 00 = Black 0XFF00FF, _ ; 0x1 = 01 = Magenta 0X0000A0, _ ; 0x2 = 02 = Dark Blue 0X800080, _ ; 0x3 = 03 = Purple 0X006400, _ ; 0x4 = 04 = Dark Green 0X808080, _ ; 0x5 = 05 = Grey 0X0000CD, _ ; 0x6 = 06 = Medium Blue 0XADD8E6, _ ; 0x7 = 07 = Light Blue 0XA52A2A, _ ; 0x8 = 08 = Brown 0XFFA500, _ ; 0x9 = 09 = Orange 0XD3D3D3, _ ; 0xA = 10 = Light Grey 0XFFC0CB, _ ; 0xB = 11 = Pink 0X008000, _ ; 0xC = 12 = Green 0XFFFF00, _ ; 0xD = 13 = Yellow 0X00FFFF, _ ; 0xE = 14 = Aqua 0xFFFFFF]; ; 0xF = 15 = White Global $MyGui = GUICreate("", 335, 630, -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE, $WS_EX_COMPOSITED, $WS_EX_LAYERED)) $hGlass = GUICtrlCreateLabel("", 0, 0, 335, 630, -1, $GUI_WS_EX_PARENTDRAG) ; Protect the RichEdit and allows to drag the GUI around GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ; This is like a glass over the underlying RichEdit GUICtrlSetCursor(-1, 2) ; Cursor is an arrow (instead of the default I-beam) ; ; This RichEdit is used to simulate the LoRes Graphic of tha Apple 2 (40x40 pixels) Global $hGR = _GUICtrlRichEdit_Create($MyGui, $sBuffer, 0, 0, 335, 630, BitOR($ES_READONLY, $ES_MULTILINE)) _GUICtrlRichEdit_SetSel($hGR, 0, -1) _GUICtrlRichEdit_SetFont($hGR, 10, "Courier new") _GUICtrlRichEdit_SetBkColor($hGR, 0xffffff) GUISetState() ; Main loop ; --------- While 1 For $W = 3 To 50 For $x = 19 To 1 Step -1 For $y = 19 To 0 Step -1 $xy = $x + $y $iColor = Mod(Int($y * 3 / ($x + 3) + $x * $W / 12), 16) $sChar = ChrW(32 + $iColor) ; comment this if you don't want chars (only color) If $iColor > 15 Then $iColor = 15 Print($sChar, $x, $xy, $iColor) Print($sChar, $xy, $x, $iColor) Print($sChar, 40 - $x, 40 - $xy, $iColor) Print($sChar, 40 - $xy, 40 - $x, $iColor) Print($sChar, $xy, 40 - $x, $iColor) Print($sChar, 40 - $x, $xy, $iColor) Print($sChar, $x, 40 - $xy, $iColor) Print($sChar, 40 - $xy, $x, $iColor) Next Next Next WEnd ; Print a char to Htab (Horiz. pos), Vtab (Vert pos) on the RichEdit ; ------------------------------------------------------------------ Func Print($sChar = "", $iHtab = 1, $iVtab = 1, $iColor = 0xffffff) _GUICtrlRichEdit_SetSel($hGR, GetAbsPos($iHtab, $iVtab), GetAbsPos($iHtab, $iVtab) + 1, True) _GUICtrlRichEdit_SetCharBkColor($hGR, $aApplesoft_color[$iColor]) _GUICtrlRichEdit_ReplaceText($hGR, $sChar, False) EndFunc ;==>Print ; From Htab Vtab (1 based) to Absolute position within the RichEdit ; ----------------------------------------------------------------- Func GetAbsPos($iHtab = 1, $iVtab = 1, $iScreenWidth = $iHwidth) Return ($iVtab - 1) * ($iScreenWidth + 2) + $iHtab EndFunc ;==>GetAbsPos ; returns one or more chars replicated n times ; Example: ConsoleWrite(_StringReplay('*', 5) & @CRLF) Func _StringReplay($sChars = "", $iRepeats = 0) $sChars = String($sChars) $iRepeats = Int(Abs(Number($iRepeats))) Return StringReplace(StringFormat('%' & $iRepeats & 's', ""), " ", $sChars) EndFunc ;==>_StringReplay Func _TheEnd() If WinActive("[ACTIVE]") = $MyGui Then _GUICtrlRichEdit_Destroy($hGR) Exit EndIf EndFunc ;==>_TheEnd  
    • golfinhu
      By golfinhu
      Hi, ppl.

      I am developing a GUI with a fix sidebar, based on the style of windows 10 ... I have 3 problems at the moment.
      1 - How do I put the close and minimize buttons on my window? (I want my window not to have the top bar). I tried to draw with gdi plus but I could not.
      2 - My watch flashes when the time is updated. I tried to do with _GDIPlus_GraphicsDrawString but the strings get overlapped.
      3 - I can not leave my transparent buttons to put them in the sidebar (as in this photo below)

      If anyone can help me I would appreciate it very much.
      thanks a lot
       
      GUI.au3
    • UEZ
      By UEZ
      Here my contribution to the clock fever - nothing special rather a fast hack:
      Download:  AutoIt Eye Clock v1.3.1 build 2015-06-28.7z
       
      Left eye = hour, right eye = minutes, pupil light = seconds

       
       
       
       
       


       
      You can rename the compiled script to *.scr to behave as an screensaver. Furthermore you can copy the *.scr to System32 (x86 system) or SysWOW64 (x64 system) and configure it as a screensaver incl. preview.
       
      Original clock: http://www.suck.uk.com/products/eyeclock/
       
      Have fun.
    • Melba23
      By Melba23
      The Fibonacci clock lets you know the time by changing colours and requiring you do some adding up.

      The Fibonacci sequence is the sequence beginning 1, 1 and where each number is the sum of the previous two. Its first five digits are: 1, 1, 2, 3, 5.  These numbers are all you need to express all the numbers from 1 to 12.
      1 = 1
      1+1 = 2
      ...
      1 + 1 + 2 + 3 + 5 = 12
      which means that it is possible to use them to describe the twelve positions on a clock, and therefore tell the time in 5 minute intervals.
      Philippe Chrétien of Montreal Canada made such a clock with squares of side length 1, 1, 2, 3, and 5 (the numbers in the Fibonacci sequence) arranged into a "golden rectangle".  The squares lit up in red tell you the hour, and in green give you the minutes (in multiples of five). A square lit up in blue meant it is to be added for both hour and minute. Transparent squares are ignored.

      The first example below decodes as follows:
      Hours, red 5, red 1 and blue 3 = 5 + 1 + 3 = 9 hours
      Minutes: green 2 and blue 3 = 2 + 3 = 5.  5 x 5 = 25 minutes.
      So, the time is 9.25.

      And here is a little script to show how you can create a Fibonacci clock of your own - by default it shows the current time (which you can reset at any time using the "Reset" button) or you can test it by entering a time in the combos:
      #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <Date.au3> $iMargin_X = 10 $iMargin_Y = 10 $iMargin_Inter = 5 $iSize = 50 $iButton_Level = ($iSize * 5) + $iMargin_Inter + 20 $hGUI = GUICreate("Fibonacci Clock", ($iSize * 8) + ($iMargin_X * 2), $iButton_Level + 100) GUISetBkColor(0xC4C4C4) $cBack = GUICtrlCreateLabel("", $iMargin_X - $iMargin_Inter, $iMargin_Y - $iMargin_Inter, _ ($iSize * 8) + ($iMargin_Inter * 2), ($iSize * 5) + $iMargin_Inter) GUICtrlSetBkColor($cBack, 0x000000) $cLabel_1A = GUICtrlCreateLabel("", $iMargin_X + ($iSize * 2), $iMargin_Y, $iSize - $iMargin_Inter, $iSize - $iMargin_Inter) $cLabel_1B = GUICtrlCreateLabel("", $iMargin_X + ($iSize * 2), $iMargin_Y + $iSize, $iSize - $iMargin_Inter, $iSize - $iMargin_Inter) $cLabel_2 = GUICtrlCreateLabel("", $iMargin_X, $iMargin_Y, ($iSize * 2) - $iMargin_Inter, ($iSize * 2) - $iMargin_Inter) $cLabel_3 = GUICtrlCreateLabel("", $iMargin_X, $iMargin_Y + ($iSize * 2), ($iSize * 3) - $iMargin_Inter, ($iSize * 3) - $iMargin_Inter) $cLabel_5 = GUICtrlCreateLabel("", $iMargin_X + ($iSize * 3), $iMargin_Y, $iSize * 5, ($iSize * 5) - $iMargin_Inter) $cUserSet = GUICtrlCreateButton("Set User Time", $iMargin_X, $iButton_Level, 100, 30) $cUserHour = GUICtrlCreateCombo("", $iMargin_X + 120, $iButton_Level, 40, 20) GUICtrlSetData($cUserHour, "00|01|02|03|04|05|06|07|08|09|10|11|12") $cUserMin = GUICtrlCreateCombo("", $iMargin_X + 160, $iButton_Level, 40, 20) GUICtrlSetData($cUserMin, "00|05|10|15|20|25|30|35|40|45|50|55") $cReset = GUICtrlCreateButton("Reset Current Time", $iMargin_X, $iButton_Level + 50, 120, 30) GUICtrlCreateLabel("Hours:" & @CRLF & @CRLF & "Mins:" & @CRLF & @CRLF & "Both:", 250, $iButton_Level, 150, 80) GUICtrlCreateLabel("", 300, $iButton_Level, 50, 20) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlCreateLabel("", 300, $iButton_Level + 25, 50, 20) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlCreateLabel("", 300, $iButton_Level + 50, 50, 20) GUICtrlSetBkColor(-1, 0x0000FF) GUISetState() _Reset() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cReset _Reset() Case $cUserSet $iHour = GUICtrlRead($cUserHour) $iMin = GUICtrlRead($cUserMin) / 5 _Set_Clock($iHour, $iMin) EndSwitch WEnd Func _Reset() $sDTG = _NowCalc() $iHour = StringRegExpReplace($sDTG, "^.*\s(\d\d):.*", "$1") $iHour = (($iHour > 12) ? ($iHour - 12) : ($iHour)) $iMin = Int(StringRegExpReplace($sDTG, "^.*:(\d\d):.*", "$1") / 5) _Set_Clock($iHour, $iMin) EndFunc ;==>_Reset Func _Set_Clock($iH, $iM) $iH = Number($iH) $iM = Number($iM) ;ConsoleWrite("Entry: " & $iH & " - " & $iM & @CRLF) GUICtrlSetBkColor($cLabel_1A, 0xC4C4C4) GUICtrlSetBkColor($cLabel_1B, 0xC4C4C4) GUICtrlSetBkColor($cLabel_2, 0xC4C4C4) GUICtrlSetBkColor($cLabel_3, 0xC4C4C4) GUICtrlSetBkColor($cLabel_5, 0xC4C4C4) $iState_1A = 0 $iState_1B = 0 $iState_2 = 0 $iState_3 = 0 $iState_5 = 0 While $iH ;ConsoleWrite($iH & @CRLF) Switch $iH Case 5 To 12 ;;ConsoleWrite("5-12" & @CRLF) If Not $iState_5 Then ;;ConsoleWrite("- 5" & @CRLF) $iH -= 5 GUICtrlSetBkColor($cLabel_5, 0XFF0000) $iState_5 = 1 Else ContinueCase EndIf Case 3 To 12 ;;ConsoleWrite("3-12" & @CRLF) If Not $iState_3 Then ;;ConsoleWrite("- 3" & @CRLF) $iH -= 3 GUICtrlSetBkColor($cLabel_3, 0XFF0000) $iState_3 = 1 Else ContinueCase EndIf Case 2 To 12 ;;ConsoleWrite("2-12" & @CRLF) If Not $iState_2 Then ;;ConsoleWrite("- 2" & @CRLF) $iH -= 2 GUICtrlSetBkColor($cLabel_2, 0XFF0000) $iState_2 = 1 Else ContinueCase EndIf Case Else ;;ConsoleWrite("Else" & @CRLF) If $iState_1A Then ;;ConsoleWrite("- 1B" & @CRLF) $iH -= 1 GUICtrlSetBkColor($cLabel_1B, 0XFF0000) $iState_1B = 1 Else ;;ConsoleWrite("- 1A" & @CRLF) $iH -= 1 GUICtrlSetBkColor($cLabel_1A, 0XFF0000) $iState_1A = 1 EndIf EndSwitch WEnd While $iM Switch $iM Case 5 To 12 $bContinueCase = False ;ConsoleWrite("5-12" & @CRLF) Switch $iState_5 Case 0 ;ConsoleWrite("-5:G" & @CRLF) $iM -= 5 GUICtrlSetBkColor($cLabel_5, 0X00FF00) $iState_5 = 2 Case 1 ;ConsoleWrite("-5:B" & @CRLF) $iM -= 5 GUICtrlSetBkColor($cLabel_5, 0X0000FF) $iState_5 = 2 Case 2 $bContinueCase = True EndSwitch If $bContinueCase Then ContinueCase Case 3 To 12 ;ConsoleWrite("3-12" & @CRLF) $bContinueCase = False Switch $iState_3 Case 0 ;ConsoleWrite("-3:G" & @CRLF) $iM -= 3 GUICtrlSetBkColor($cLabel_3, 0X00FF00) $iState_3 = 2 Case 1 ;ConsoleWrite("-3:B" & @CRLF) $iM -= 3 GUICtrlSetBkColor($cLabel_3, 0X0000FF) $iState_3 = 2 Case 2 $bContinueCase = True EndSwitch If $bContinueCase Then ContinueCase Case 2 To 12 ;ConsoleWrite("2-12" & @CRLF) $bContinueCase = False Switch $iState_2 Case 0 ;ConsoleWrite("-2:G" & @CRLF) $iM -= 2 GUICtrlSetBkColor($cLabel_2, 0X00FF00) $iState_2 = 2 Case 1 ;ConsoleWrite("-2:B" & @CRLF) $iM -= 2 GUICtrlSetBkColor($cLabel_2, 0X0000FF) $iState_2 = 2 Case 2 $bContinueCase = True EndSwitch If $bContinueCase Then ContinueCase Case Else Switch $iState_1A Case 2 $iM -= 1 If $iState_1B Then ;ConsoleWrite("-1B:B" & @CRLF) GUICtrlSetBkColor($cLabel_1B, 0X0000FF) Else ;ConsoleWrite("-1B:G" & @CRLF) GUICtrlSetBkColor($cLabel_1B, 0X00FF00) EndIf Case 1 ;ConsoleWrite("-1A:B" & @CRLF) $iM -= 1 If $iState_1B = 0 Then GUICtrlSetBkColor($cLabel_1B, 0x00FF00) $iState_1B = 1 Else GUICtrlSetBkColor($cLabel_1A, 0x0000FF) $iState_1A = 2 EndIf Case Else ;ConsoleWrite("-1A:G" & @CRLF) $iM -= 1 GUICtrlSetBkColor($cLabel_1A, 0x00FF00) $iState_1A = 1 EndSwitch EndSwitch WEnd EndFunc ;==>_Set_Clock If anyone can produce shorter internal code to colour the labels, please do post it - I found that quite a difficult problem to crack and I am certain I do not have an optimal solution.
      M23
      P.S. The original clock:
       
    • Chimp
      By Chimp
      ....from the  serie "strange clocks":
      see here for infos on how to read this clock
      ; Berlin-Uhr HotKeySet("{Esc}", "End") Global $aColors[3] = ["0x757575", "0xFFCC00", "0xFF0033"] ; [off][yellow][red] Local $iSec = 0, $iMin = 0 Global $hGui = GUICreate(' Berlin-Uhr', 275, 240) ; ($nrPerLine, $ctrlWidth, $ctrlHeight, $xPanelPos, $yPanelPos, $xSpace) Local $aGuiSecsX2 = _GuiPanel(01, 55, 35, 115, 010, 5) ; Seconds blink Local $aGuiHourX5 = _GuiPanel(04, 55, 35, 025, 055, 5) ; Hours * 5 Local $aGuiHourX1 = _GuiPanel(04, 55, 35, 025, 100, 5) ; Hours Local $aGuiMinsX5 = _GuiPanel(11, 16, 35, 025, 145, 6) ; Mins * 5 Local $aGuiMinsX1 = _GuiPanel(04, 55, 35, 025, 190, 5) ; Mins GUISetBkColor("0x9A9A9A", $hGui) GUISetState(@SW_SHOW) Do If @SEC <> $iSec Then ; when the second changes do what following $iSec = @SEC GUICtrlSetBkColor($aGuiSecsX2[1], $aColors[@SEC / 2 = Int(@SEC / 2)]) ; second blink If @MIN <> $iMin Then $iMin = @MIN For $i = 1 To 11 If $i < 5 Then GUICtrlSetBkColor($aGuiHourX5[$i], $aColors[2 * (Int(@HOUR / 5) >= $i)]) GUICtrlSetBkColor($aGuiHourX1[$i], $aColors[2 * (Mod(@HOUR, 5) >= $i)]) GUICtrlSetBkColor($aGuiMinsX1[$i], $aColors[Mod(@MIN, 5) >= $i]) EndIf GUICtrlSetBkColor($aGuiMinsX5[$i], $aColors[(Int(@MIN / 5) >= $i) * (1 + ($i = 3 Or $i = 6 Or $i = 9))]) Next EndIf EndIf Until GUIGetMsg() = -3 ; $GUI_EVENT_CLOSE End() Func _GuiPanel($nrPerLine, $ctrlWidth, $ctrlHeight, $xPanelPos, $yPanelPos, $xSpace = 1) ; create the controls Local $aGuiGridCtrls[$nrPerLine + 1] For $i = 1 To $nrPerLine $left = $xPanelPos + ((($ctrlWidth + $xSpace) * ($i - 1)) - $xSpace) $aGuiGridCtrls[$i] = GUICtrlCreateInput("", $left, $yPanelPos, $ctrlWidth, $ctrlHeight, 0x0800) ; 0x0800 = $ES_READONLY GUICtrlSetBkColor(-1, $aColors[0]) Next Return $aGuiGridCtrls EndFunc ;==>_GuiPanel Func End() If WinActive($hGui) Then GUIDelete($hGui) Exit EndIf EndFunc ;==>End