Jump to content

BiClock, yet!


Michel Claveau
 Share

Recommended Posts

Hi!

I have write this code to spend time, because my wife was late...

#include <Array.au3>

$ai2 = _ArrayCreate(0,0,0)
$ai22 = _ArrayCreate(0,0,0)
$buffer=_ArrayCreate("","","")

For $x=1 To 60*60*24
    Sleep(990)
    $temps=_ArrayCreate(nbbin(Int(@HOUR)),nbbin(Int(@MIN)),nbbin(Int(@SEC)))
    ScreenText($temps , 0, 10, 20)
Next



Func nbbin($nb)
    $bits = _ArrayCreate("0","0","0","0","0","0")
    $i=32
    For $j=0 To 5
        If Int($nb/$i)>0 Then   
            $bits[$j]="1"
            $nb-=$i
        EndIf
        $i=$i/2
    Next
    Return _ArrayToString($bits,"")
EndFunc


Func ScreenText($txt, $duree, $x,$y)
    $size=32
    $inc=$size*3/4
    For $i=0 To 2
        If $txt[$i]<>$buffer[$i] Then
            $buffer[$i]=$txt[$i]
            $long=Stringlen($txt[$i])
            If $ai22[$i]<>0 Then
                GUIDelete($ai22[$i])
            EndIf
            $ai22[$i] = GUICreate("Text Region",$long*$size,$size,$x+3,$y+2+$inc*$i,$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
            GUISetBkColor(0x000000)
            $rgn22 = CreateTextRgn($ai22[$i],$txt[$i],$size,"Arial Narrow",1000)
            SetWindowRgn($ai22[$i],$rgn22)
            GUISetState()
    
            If $ai2[$i]<>0 Then
                GUIDelete($ai2[$i])
            EndIf
            $ai2[$i] = GUICreate("Text Region",$long*$size,$size,$x,$y+$inc*$i,$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
            GUISetBkColor(0xFFFF00)
            $rgn2 = CreateTextRgn($ai2[$i],$txt[$i],$size,"Arial Narrow",1000)
            SetWindowRgn($ai2[$i],$rgn2)
            GUISetState()
        EndIf
    Next
EndFunc


Func SetWindowRgn($h_win, $rgn)
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc


Func CreateTextRgn(ByRef $CTR_hwnd,$CTR_Text,$CTR_height,$CTR_font="Microsoft Sans Serif",$CTR_weight=1000)
    Local Const $ANSI_CHARSET = 0
    Local Const $OUT_CHARACTER_PRECIS = 2
    Local Const $CLIP_DEFAULT_PRECIS = 0
    Local Const $PROOF_QUALITY = 2
    Local Const $FIXED_PITCH = 1
    Local Const $RGN_XOR = 3
    
    If $CTR_font = "" Then $CTR_font = "Microsoft Sans Serif"
    If $CTR_weight = -1 Then $CTR_weight = 1000
    Local $gdi_dll = DLLOpen("gdi32.dll")
    Local $CTR_hDC= DLLCall("user32.dll","int","GetDC","hwnd",$CTR_hwnd)
    Local $CTR_hMyFont = DLLCall($gdi_dll,"hwnd","CreateFont","int",$CTR_height,"int",0,"int",0,"int",0, _
                "int",$CTR_weight,"int",0,"int",0,"int",0,"int",$ANSI_CHARSET,"int",$OUT_CHARACTER_PRECIS, _
                "int",$CLIP_DEFAULT_PRECIS,"int",$PROOF_QUALITY,"int",$FIXED_PITCH,"str",$CTR_font )
    Local $CTR_hOldFont = DLLCall($gdi_dll,"hwnd","SelectObject","int",$CTR_hDC[0],"hwnd",$CTR_hMyFont[0])
    DLLCall($gdi_dll,"int","BeginPath","int",$CTR_hDC[0])
    DLLCall($gdi_dll,"int","TextOut","int",$CTR_hDC[0],"int",0,"int",0,"str",$CTR_Text,"int",StringLen($CTR_Text))
    DLLCall($gdi_dll,"int","EndPath","int",$CTR_hDC[0])
    Local $CTR_hRgn1 = DLLCall($gdi_dll,"hwnd","PathToRegion","int",$CTR_hDC[0])
    Local $CTR_rc = DLLStructCreate("int;int;int;int")
    DLLCall($gdi_dll,"int","GetRgnBox","hwnd",$CTR_hRgn1[0],"ptr",DllStructGetPtr($CTR_rc))
    Local $CTR_hRgn2 = DLLCall($gdi_dll,"hwnd","CreateRectRgnIndirect","ptr",DllStructGetPtr($CTR_rc))
    DLLCall($gdi_dll,"int","CombineRgn","hwnd",$CTR_hRgn2[0],"hwnd",$CTR_hRgn2[0],"hwnd",$CTR_hRgn1[0],"int",$RGN_XOR)
    DLLCall($gdi_dll,"int","DeleteObject","hwnd",$CTR_hRgn1[0])
    DLLCall("user32.dll","int","ReleaseDC","hwnd",$CTR_hwnd,"int",$CTR_hDC[0])
    DLLCall($gdi_dll,"int","SelectObject","int",$CTR_hDC[0],"hwnd",$CTR_hOldFont[0])
    DLLClose($gdi_dll)
    Return $CTR_hRgn2[0]
EndFunc
Edited by Michel Claveau
Link to comment
Share on other sites

Hi!

From my prior code, I have get a mini-mini binary-clock:

Dim $bit[2]=["0","1"]
For $x=1 To 60*60*24
    sleep(990)
    ToolTip(nbbin(@HOUR) & nbbin(@MIN) & nbbin(@SEC), 10, 10)
Next

Func nbbin($nb)
    $bits = " "
    For $j = 5 To 0 Step -1
        $bits &= $bit[BitAND(Int($nb),2^$j)/2^$j]
    Next
    Return $bits & @CRLF
EndFunc

Only good for understand Autoit... (or like begin of a BigBinaryClock)

:)

Edited by Michel Claveau
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...