WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Cute Binary Clock Example

Keywords: 	 binary clock

Just for fun, here is a clock that displays the time in binary. Maximized, it makes an interesting "screen saver".

Have some fun,
Russell


; Binary clock
; by Russell
; 
; Edit {snowsnowsnow} 6/24/07; eliminate use of WilX extender
; Modified {snowsnowsnow} 6/30/07; to run as a screen saver
; Compile to small EXE, then copy the EXE to your System32 dir, with .SCR ext

#DefineSubroutine DrawTime(num,color,symbol)
FOR I = 1 TO 6
    IF num & PowOf2[i]
	BoxColor(2,color,0)
    ELSE
	BoxColor(2,BLACK,0)
    ENDIF
    BoxDrawCircle(2,%symbol%%i%,2)
NEXT
#EndSubroutine

; Mainline starts here...
ProgDate = "Binary Clock"
Terminate("%Param1%" != "/s",ProgDate,StrCat("Args passed: ",IntControl(1006,0,0,0,0)))
; Hide Title Bar
SWP_FRAMECHANGED = 32
HWND_TOP = 0
SWP_NOMOVE = 2
SWP_NOSIZE = 1
WS_CAPTION = 12582912
GWL_STYLE = -16
u32 = DllLoad("user32.dll")
MyHand = DllHwnd("")
OldStyle = DllCall(u32,long:"GetWindowLongA",long:MyHand,long:GWL_STYLE)
NewStyle = OldStyle & ~WS_CAPTION
DllCall(u32,long:"SetWindowLongA",long:MyHand,long:GWL_STYLE,long:NewStyle)
DllCall(u32,long:"SetWindowPos",long:MyHand,long:HWND_TOP,long:0,long:0,long:0,long:0,long:SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE)
clock12 = 1 ; If you want a 12 hour clock (AM/PM), set this to 1. Otherwise, hours are 0 - 23
PowOf2 = Arrayize("0 32 16 8 4 2 1"," ")
MousePos = MouseInfo(2)

DKBLUE="0,0,128"
BLUE="0,0,255"
LTBLUE="128,180,255"
LTGRAY="192,192,192"
GRAY="150,150,150"
DKGRAY="64,64,64"
GREEN="0,255,0"
RED="255,0,0"
BLACK="0,0,0"
WHITE="255,255,255"
YELLOW="255,255,0"

BoxesUp("0,0,100,125",@normal)
BoxNew(2,"0,0,1000,1000",0)
BoxColor(2,BLACK,0)
BoxDrawRect(2,"0,0,1000,1000",2)
BoxDataTag(2,"Time")

; Assign window positions for binary 1 or 0 for hour, minute, second
; Since we'll only see a max value of 59 (111011), we only need 6 positions.
sec6 = "800,750,900,900" ; Position of seconds 1
sec5 = "660,750,760,900" ;                    2
sec4 = "520,750,620,900" ;                    4
sec3 = "380,750,480,900" ;                    8
sec2 = "240,750,340,900" ;                   16
sec1 = "100,750,200,900" ;                   32
min6 = "800,500,900,650"
min5 = "660,500,760,650"
min4 = "520,500,620,650"
min3 = "380,500,480,650"
min2 = "240,500,340,650"
min1 = "100,500,200,650"
hour6 = "800,250,900,400"
hour5 = "660,250,760,400"
hour4 = "520,250,620,400"
hour3 = "380,250,480,400"
hour2 = "240,250,340,400"
hour1 = "100,250,200,400"

WinZoom("")
:loop
BoxDataClear(2,"Time")
TOD = TimeYmdHms()

hours = ItemExtract(4,TOD,":")
SWITCH 1
CASE !clock12
    BoxCaption(1,"24 Hour Clock")
    Break
CASE hours >= 12
    IF hours > 12 THEN hours = hours - 12
    BoxCaption(1,"PM")
    Break
CASE !hours
    hours = 12
CASE 1
    BoxCaption(1,"AM")
ENDSWITCH
DrawTime(hours,RED,"hour")
DrawTime(ItemExtract(5,TOD,":"),BLUE,"min")
DrawTime(ItemExtract(6,TOD,":"),GREEN,"sec")
TimeDelay(-0.5)
IF MousePos == MouseInfo(2) THEN goto loop

Article ID:   W14953
File Created: 2007:07:16:13:39:24
Last Updated: 2007:07:16:13:39:24