Sign in to follow this  
Followers 0
sak

Easy Digital Clock

7 posts in this topic

I spent a day designing this program. I think it's easy for you to try this type of programming. :)

#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", 1)

Global $Gui, $Grap, $Lbl1, $Lbla, $Lbl2, $Lblb, $Lbl3, $Lblc
Global $Lbl4, $Lbl5, $Lbl6, $Lbl7, $Lbl8, $Lbl9, $Lbl10, $Lbl11
Global $nMsg, $dw, $rdw, $my, $dm, $ay, $hh, $mm, $ss, $gencol, $ht

$Gui = GUICreate("DIGITAL CLOCK", 290, 111, -1, -1, -1, _
BitOR($WS_EX_OVERLAPPEDWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUISetBkColor(0x808000)
$Grap = GUICtrlCreateGraphic(8, 8, 272, 92, _
BitOR($SS_CENTER,$SS_RIGHT,$SS_BLACKRECT,$SS_GRAYRECT,$SS_WHITERECT, _
$SS_BLACKFRAME,$SS_NOTIFY,$SS_SUNKEN,$WS_GROUP))
GUICtrlSetBkColor(-1, 0x575C64)
$Lbl1 = GUICtrlCreateLabel("--", 75, 10, 24, 22)
GUICtrlSetFont(-1, 12, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbla = GUICtrlCreateLabel("\", 98, 10, 24, 22)
GUICtrlSetFont(-1, 12, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl2 = GUICtrlCreateLabel("--", 110, 10, 24, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lblb = GUICtrlCreateLabel("/", 130, 10, 24, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl3 = GUICtrlCreateLabel("--", 140, 10, 24, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lblc = GUICtrlCreateLabel("/", 160, 10, 24, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl4 = GUICtrlCreateLabel("----", 170, 10, 44, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl5 = GUICtrlCreateLabel("00", 5, 35, 80, 61, $SS_CENTER)
GUICtrlSetFont(-1, 35, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl6 = GUICtrlCreateLabel("00", 75, 35, 80, 61, $SS_CENTER)
GUICtrlSetFont(-1, 35, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl7 = GUICtrlCreateLabel("00", 147, 35, 80, 61, $SS_CENTER)
GUICtrlSetFont(-1, 35, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl8 = GUICtrlCreateLabel("--", 227, 42, 48, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl9 = GUICtrlCreateLabel(":", 58, 31, 47, 61, $SS_CENTER)
GUICtrlSetFont(-1, 35, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl10 = GUICtrlCreateLabel(":", 129, 31, 47, 61, $SS_CENTER)
GUICtrlSetFont(-1, 35, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl11 = GUICtrlCreateLabel(":", 210, 42, 31, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case 0
            GUICtrlSetData($Lbl1, _DaysOfWeek())
            GUICtrlSetData($Lbl2, _MonthsOfYear())
            GUICtrlSetData($Lbl3, _DaysOfMonth())
            GUICtrlSetData($Lbl4, _Years())
            GUICtrlSetData($Lbl5, _Hours())
            GUICtrlSetData($Lbl6, _Minites())
            GUICtrlSetData($Lbl7, _Seconds())
            _Generator()
            _HalfTime()
    EndSwitch
WEnd

Func _DaysOfWeek()
    $dw = (@WDAY)
    Switch $dw
        Case 1
            $rdw = 'SU'
        Case 2
            $rdw = 'MO'
        Case 3
            $rdw = 'TU'
        Case 4
            $rdw = 'WE'
        Case 5
            $rdw = 'TH'
        Case 6
            $rdw = 'FI'
        Case 7
            $rdw = 'SA'
    EndSwitch
    Return $rdw
EndFunc

Func _MonthsOfYear()
    $my = (@MON)
    Return $my
EndFunc

Func _DaysOfMonth()
$dm = (@MDAY)
Return $dm
EndFunc

Func _Years()
$ay = (@YEAR)
Return $ay
EndFunc

Func _Hours()
$hh = (@HOUR)
Return $hh
EndFunc

Func _Minites()
$mm = (@MIN)
Return $mm
EndFunc

Func _Seconds()
$ss = (@SEC)
Return $ss
EndFunc

Func _Generator()
    $gencol = (GUICtrlSetColor($Lbl11, 0x000000))
        Sleep(500)
    If $gencol Then
        GUICtrlSetColor($Lbl11, 0xFF0000)
        Sleep(500)
    EndIf
    Return $gencol
EndFunc

Func _HalfTime()
    If @HOUR > 12 Then
        $ht = (GUICtrlSetData($Lbl8, 'PM'))
    Else
        $ht = (GUICtrlSetData($Lbl8, 'AM'))
    EndIf
        Return $ht
EndFunc

post-63570-0-85003100-1300029309_thumb.j

Share this post


Link to post
Share on other sites



Nicely done ! Posted Image

you should add a tray menu for change date format and hour format 12/24

or colors...


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I wrote a digital clock script not to long ago using LED gifs.

This one is also simple and I will share it with you.

Global Const $USER_DEFAULT=1024,$GREGORIAN=1
Global Const $MONTH_NAME=20,$ABV_MONTH_NAME=33
Global Const $DAY_NAME=5,$ABV_DAY_NAME=12
Global Const $WS_EX_TOOLWINDOW=128,$WS_EX_TOPMOST=8

Func Get_Date($IN)
    Local $Ret=DllCall("kernel32.dll","int","GetCalendarInfo","int",$USER_DEFAULT, _
                                                              "int",$GREGORIAN, _
                                                              "int",$IN, _
                                                              "str",0, _
                                                              "int",10, _
                                                              "int",0)
    Return $Ret[4]
EndFunc

Func Clock()
    Local $T[7]
    $AmPm=""
    $pID=Run(@ComSpec&" /c time /t","",@SW_HIDE,3)
    Do
        $AmPm&=StdoutRead($pID)
    Until @error
    $T[0]=StringLeft($AmPm,1)
    $T[1]=StringMid($AmPm,2,1)
    $T[2]=StringLeft(@MIN,1)
    $T[3]=StringRight(@MIN,1)
    $T[4]=StringLeft(@SEC,1)
    $T[5]=StringRight(@SEC,1)
    $T[6]=StringRight(StringStripWS($AmPm,2),2)
    For $I=5 To 0 Step -1
        GUICtrlSetImage($Time[$I],$sd.Item($T[$I]))
    Next
    GUICtrlSetData($Time[6],$T[6])
EndFunc

$sd=ObjCreate("Scripting.Dictionary")
$sd.Add("0",@ScriptDir&"\0Led.gif")
$sd.Add("1",@ScriptDir&"\1Led.gif")
$sd.Add("2",@ScriptDir&"\2Led.gif")
$sd.Add("3",@ScriptDir&"\3Led.gif")
$sd.Add("4",@ScriptDir&"\4Led.gif")
$sd.Add("5",@ScriptDir&"\5Led.gif")
$sd.Add("6",@ScriptDir&"\6Led.gif")
$sd.Add("7",@ScriptDir&"\7Led.gif")
$sd.Add("8",@ScriptDir&"\8Led.gif")
$sd.Add("9",@ScriptDir&"\9Led.gif")

Global $Time[7]
Local $W=41,$H=79,$Green=0x00FF00
Local $Date=Get_Date($DAY_NAME+@WDAY)&", "&Get_Date($MONTH_NAME+@MON)&" "&@MDAY&", "&@YEAR

GUICreate("LED Clock - "&$Date,410,80,-1,-1,Default,$WS_EX_TOOLWINDOW+$WS_EX_TOPMOST)
GUISetBkColor(0)

$Time[0]=GUICtrlCreatePic($sd.Item("0"),0,0,$W,$H)
$Time[1]=GUICtrlCreatePic($sd.Item("0"),48,0,$W,$H)
GUICtrlCreateLabel(":",98,0,$W,$H)
GUICtrlSetFont(-1,46,800)
GUICtrlSetColor(-1,$Green)

$Time[2]=GUICtrlCreatePic($sd.Item("0"),128,0,$W,$H)
$Time[3]=GUICtrlCreatePic($sd.Item("0"),178,0,$W,$H)
GUICtrlCreateLabel(":",225,0,$W,$H)
GUICtrlSetFont(-1,46,800)
GUICtrlSetColor(-1,$Green)

$Time[4]=GUICtrlCreatePic($sd.Item("0"),255,0,$W,$H)
$Time[5]=GUICtrlCreatePic($sd.Item("0"),305,0,$W,$H)
$Time[6]=GUICtrlCreateLabel("",355,0,50,79)
GUICtrlSetFont(-1,26,800)
GUICtrlSetColor(-1,$Green)

GUISetState()
AdlibRegister("Clock",1000)

While GUIGetMsg()<>-3
WEnd
$sd=0

Go Here... Ledgif.zip

Edited by xroot

Share this post


Link to post
Share on other sites

I wrote a digital clock script not to long ago using LED gifs.

This one is also simple and I will share it with you.

Where can i find them ?


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

sak

Normally , but not worth every second to get minutes, hours , days, months and years.

Func _Seconds()
$ss = @SEC
If $ss = 00 Then GUICtrlSetData($Lbl6, _Minites())
Return $ss
EndFunc

Check it out, but I have not tested

#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", 1)

Global $Gui, $Grap, $Lbl1, $Lbla, $Lbl2, $Lblb, $Lbl3, $Lblc
Global $Lbl4, $Lbl5, $Lbl6, $Lbl7, $Lbl8, $Lbl9, $Lbl10, $Lbl11
Global $nMsg, $dw, $rdw, $my, $dm, $ay, $hh, $mm, $ss, $gencol, $ht

$Gui = GUICreate("DIGITAL CLOCK", 290, 111, -1, -1, -1, _
BitOR($WS_EX_OVERLAPPEDWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUISetBkColor(0x808000)
$Grap = GUICtrlCreateGraphic(8, 8, 272, 92, _
BitOR($SS_CENTER,$SS_RIGHT,$SS_BLACKRECT,$SS_GRAYRECT,$SS_WHITERECT, _
$SS_BLACKFRAME,$SS_NOTIFY,$SS_SUNKEN,$WS_GROUP))
GUICtrlSetBkColor(-1, 0x575C64)
$Lbl1 = GUICtrlCreateLabel("--", 75, 10, 24, 22)
GUICtrlSetFont(-1, 12, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbla = GUICtrlCreateLabel("\", 98, 10, 24, 22)
GUICtrlSetFont(-1, 12, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl2 = GUICtrlCreateLabel("--", 110, 10, 24, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lblb = GUICtrlCreateLabel("/", 130, 10, 24, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl3 = GUICtrlCreateLabel("--", 140, 10, 24, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lblc = GUICtrlCreateLabel("/", 160, 10, 24, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl4 = GUICtrlCreateLabel("----", 170, 10, 44, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Courier New")
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl5 = GUICtrlCreateLabel("00", 5, 35, 80, 61, $SS_CENTER)
GUICtrlSetFont(-1, 35, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl6 = GUICtrlCreateLabel("00", 75, 35, 80, 61, $SS_CENTER)
GUICtrlSetFont(-1, 35, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl7 = GUICtrlCreateLabel("00", 147, 35, 80, 61, $SS_CENTER)
GUICtrlSetFont(-1, 35, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl8 = GUICtrlCreateLabel("--", 227, 42, 48, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl9 = GUICtrlCreateLabel(":", 58, 31, 47, 61, $SS_CENTER)
GUICtrlSetFont(-1, 35, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl10 = GUICtrlCreateLabel(":", 129, 31, 47, 61, $SS_CENTER)
GUICtrlSetFont(-1, 35, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Lbl11 = GUICtrlCreateLabel(":", 210, 42, 31, 45, $SS_CENTER)
GUICtrlSetFont(-1, 22, 800, 0, "Courier New")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

GUICtrlSetData($Lbl1, _DaysOfWeek())
GUICtrlSetData($Lbl2, @MON)
GUICtrlSetData($Lbl3, @MDAY)
GUICtrlSetData($Lbl4, @YEAR)
GUICtrlSetData($Lbl5, @HOUR)
GUICtrlSetData($Lbl6, @MIN)
GUICtrlSetData($Lbl7, @SEC)
_HalfTime()
            
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case 0
            GUICtrlSetData($Lbl7, _Seconds())
            _Generator()
    EndSwitch
WEnd

Func _DaysOfWeek()
    $dw = @WDAY
    Switch $dw
        Case 1
            $rdw = 'SU'
        Case 2
            $rdw = 'MO'
        Case 3
            $rdw = 'TU'
        Case 4
            $rdw = 'WE'
        Case 5
            $rdw = 'TH'
        Case 6
            $rdw = 'FI'
        Case 7
            $rdw = 'SA'
    EndSwitch
    Return $rdw
EndFunc

Func _MonthsOfYear()
    $my = @MON
    If $my = 01 Then GUICtrlSetData($Lbl4, _Years())
    Return $my
EndFunc

Func _DaysOfMonth()
$dm = @MDAY
If $dm = 01 Then GUICtrlSetData($Lbl2, _MonthsOfYear())
Return $dm
EndFunc

Func _Years()
$ay = @YEAR
Return $ay
EndFunc

Func _Hours()
$hh = @HOUR
If $hh = 00 Then GUICtrlSetData($Lbl3, _DaysOfMonth())
_HalfTime()
Return $hh
EndFunc

Func _Minites()
$mm = @MIN
If $mm = 00 Then GUICtrlSetData($Lbl5, _Hours())
Return $mm
EndFunc

Func _Seconds()
$ss = @SEC
If $ss = 00 Then GUICtrlSetData($Lbl6, _Minites())
Return $ss
EndFunc

Func _Generator()
    $gencol = (GUICtrlSetColor($Lbl11, 0x000000))
        Sleep(500)
    If $gencol Then
        GUICtrlSetColor($Lbl11, 0xdddd00)
        Sleep(500)
    EndIf
    Return $gencol
EndFunc

Func _HalfTime()
    If @HOUR > 12 Then
        $ht = (GUICtrlSetData($Lbl8, 'PM'))
    Else
        $ht = (GUICtrlSetData($Lbl8, 'AM'))
    EndIf
        Return $ht
EndFunc
Edited by AZJIO

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

AZJIO

You really need to ask is the ultimate compliment.

I get an idea of ​​your knowledge from multiple

I will be adjusted to write the script better. "

Thanks again. :)

-------------------------------------------------

xroot

Good, he is second to none.

To require some guidance from you.

Thank you very :)

Edited by sak

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