Jump to content

Alpha Clock by i542


i542
 Share

Recommended Posts

-> Setup (created by Setup Factory 6) which includes Source, Compiled EXE and Readme -> Download (Softpedia)

The Alpha Clock by i542 is a tiny utility with simple purpose to keep track of time. Alpha Clock looks better that the old Windows clock dispayed in the system tray and it also lets you know what date it is.

It also does not need some weird framework to run (not even the Yahoo Widget Engine!) and does just okay on all moderns Windows systems. And it is also pretty.

With the program you also get its source so you can modify it by your needs. You can also install it to USB stick (it does not need registry entries) and carry it around with you.

Based on "Launchy" by lo3dn.

-> Zipped: Files from Install without compiled EXE (Needs Auto3Lib) Alpha_Clock_by_i542.zip

Posted Image Posted Image

If you downloaded, please comment. i542 :)

EDIT: missed link

Edited by i542

I can do signature me.

Link to comment
Share on other sites

Good work. I'll try adding the toolbar functions I made to it and then you can see what you think of them in relation to your program.

EDIT: Nevermind about the toolbar thing, it doesn't work well when you have two GUI's.

Edited by Piano_Man
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Here is a sort of better version based off yours, all it does is the same thing except not military time:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=alphaico.ico
#AutoIt3Wrapper_outfile=AlphaLockClock.exe
#AutoIt3Wrapper_Compression=1
#AutoIt3Wrapper_Allow_Decompile=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <A3LGDIPlus.au3> ; this is where the magic happens, people
#include <Date.au3>

TraySetIcon(@ScriptDir & "\alphaico.ico")

TraySetToolTip("Alpha Clock gadget by i542")

Opt("TrayMenuMode", 1) ;Cleans up the menu

Global $Label

AdLibEnable("SetTime", 1000)

Opt("MustDeclareVars", 0) ;I do not have to declare variables for first use

$timer = TimerInit()

Global Const $AC_SRC_ALPHA = 1
Global Const $ULW_ALPHA = 2

TrayTip("Welcome to Alpha Clock!", "Welcome to Alpha Clock gadget by i542!", 1, 1) ;Shows the notice about the tray icon.

_GDIP_Startup()

$pngSrc = @ScriptDir & "\LaunchySkin.png" ;marks the png source...
$hImage = _GDIP_ImageLoadFromFile ($pngSrc) ;...and loads the image.

; Extract image width and height from PNG
$width = _GDIP_ImageGetWidth ($hImage)
$height = _GDIP_ImageGetHeight ($hImage)

; Create layered window
$GUI = GUICreate("Alpha Clock by i542", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW)
SetBitmap($GUI, $hImage, 0) ;I have no idea what does it mean.
; Register notification messages
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") ;???
GUISetState() ;makes it ON
WinSetOnTop($GUI, "", 1) ;makes it on top of every other window

;fade in png background
For $i = 0 To 255 Step 2
    sleep(1) ;slows down
    SetBitmap($GUI, $hImage, $i)
Next


; create child MDI gui window to hold controls
; this part could use some work - there is some flicker sometimes...
$controlGui = GUICreate("ControlGUI", $width, $height, -15, -15, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI)

; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and
; I think the way this works is the transparent window color is based on the image you set here:
GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $width, $height)
GUICtrlSetState(-1, $GUI_DISABLE)

; just a text labels


$date = GUICtrlCreateLabel(@MDAY & "." & @MON & "." & @YEAR & ".", 33, 45)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)

$label = GUICtrlCreateLabel(_NowTime(), 23, 13, 140, 50)
GUICtrlSetFont(-1, 20, -1, -1, "Arial")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)

GUISetState()
;tray menus
$info = TrayCreateItem("Crazy stats")
$about = TrayCreateItem("About the gadget")
$exit = TrayCreateItem("Close")
While 1
    $msg = TrayGetMsg()
    Switch $msg
        Case $about
            MsgBox(64, "About", "Created by i542." & @CRLF & "Skin is also created by i542" & @CRLF & "One thing I didn't create is few functions" & @CRLF & "Functions from Auto3Lib project by Paul Campbell (PaulIA). Master of these functions (he calls himself Messenger!) is lo3dn." & @CRLF & "Now also one thing I didn't created. The programming language is called AutoIt and created is by Jonnathan Bennet (spelling?) (www.autoitscript.com)" & @CRLF & "Finnaly, visit me at www.i542.net!")
        Case $exit
            ExitLoop
        Case $info
            MsgBox(64, "Crazy Stats", "You are running Alpha Clock for " & Round(TimerDiff($timer) / 1000) & " seconds." & @CRLF & "This is " & @YDAY & ". day of the year." & @CRLF & _
                    "There is " & 365 - @YDAY & " days left to the New Year" & @CRLF & "You're in " & @SEC * 1000 & ". ms")
    EndSwitch
WEnd

GUIDelete($controlGui)
;fade out png background
For $i = 255 To 0 Step - 1
    SetBitmap($GUI, $hImage, $i)
Next

; Release resources
_API_DeleteObject ($hImage)
_GDIP_Shutdown ()

; ===============================================================================================================================
; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ===============================================================================================================================
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

; ===============================================================================================================================
; SetBitMap
; ===============================================================================================================================
Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    $hScrDC = _API_GetDC (0)
    $hMemDC = _API_CreateCompatibleDC ($hScrDC)
    $hBitmap = _GDIP_BitmapCreateHBITMAPFromBitmap ($hImage)
    $hOld = _API_SelectObject ($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIP_ImageGetWidth ($hImage))
    DllStructSetData($tSize, "Y", _GDIP_ImageGetHeight ($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _API_UpdateLayeredWindow ($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _API_ReleaseDC (0, $hScrDC)
    _API_SelectObject ($hMemDC, $hOld)
    _API_DeleteObject ($hBitmap)
    _API_DeleteDC ($hMemDC)
EndFunc   ;==>SetBitmap


; I don't like AutoIt's built in ShellExec. I'd rather do the DLL call myself.
Func _ShellExecute($sCmd, $sArg = "", $sFolder = "", $rState = @SW_SHOWNORMAL)
    $aRet = DllCall("shell32.dll", "long", "ShellExecute", _
            "hwnd", 0, _
            "string", "", _
            "string", $sCmd, _
            "string", $sArg, _
            "string", $sFolder, _
            "int", $rState)
    If @error Then Return 0
    
    $RetVal = $aRet[0]
    If $RetVal > 32 Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc   ;==>_ShellExecute

Func SetTime()
    GuiCtrlSetData($Label, _NowTime())
EndFunc
Link to comment
Share on other sites

How about a hotkey that hides and shows the clock as the user wants.

Yes, I am planning to do it soon.

Here is a sort of better version based off yours, all it does is the same thing except not military time:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=alphaico.ico
#AutoIt3Wrapper_outfile=AlphaLockClock.exe
#AutoIt3Wrapper_Compression=1
#AutoIt3Wrapper_Allow_Decompile=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <A3LGDIPlus.au3> ; this is where the magic happens, people
#include <Date.au3>

TraySetIcon(@ScriptDir & "\alphaico.ico")

TraySetToolTip("Alpha Clock gadget by i542")

Opt("TrayMenuMode", 1) ;Cleans up the menu

Global $Label

AdLibEnable("SetTime", 1000)

Opt("MustDeclareVars", 0) ;I do not have to declare variables for first use

$timer = TimerInit()

Global Const $AC_SRC_ALPHA = 1
Global Const $ULW_ALPHA = 2

TrayTip("Welcome to Alpha Clock!", "Welcome to Alpha Clock gadget by i542!", 1, 1) ;Shows the notice about the tray icon.

_GDIP_Startup()

$pngSrc = @ScriptDir & "\LaunchySkin.png" ;marks the png source...
$hImage = _GDIP_ImageLoadFromFile ($pngSrc) ;...and loads the image.

; Extract image width and height from PNG
$width = _GDIP_ImageGetWidth ($hImage)
$height = _GDIP_ImageGetHeight ($hImage)

; Create layered window
$GUI = GUICreate("Alpha Clock by i542", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW)
SetBitmap($GUI, $hImage, 0) ;I have no idea what does it mean.
; Register notification messages
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") ;???
GUISetState() ;makes it ON
WinSetOnTop($GUI, "", 1) ;makes it on top of every other window

;fade in png background
For $i = 0 To 255 Step 2
    sleep(1) ;slows down
    SetBitmap($GUI, $hImage, $i)
Next
; create child MDI gui window to hold controls
; this part could use some work - there is some flicker sometimes...
$controlGui = GUICreate("ControlGUI", $width, $height, -15, -15, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI)

; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and
; I think the way this works is the transparent window color is based on the image you set here:
GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $width, $height)
GUICtrlSetState(-1, $GUI_DISABLE)

; just a text labels
$date = GUICtrlCreateLabel(@MDAY & "." & @MON & "." & @YEAR & ".", 33, 45)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)

$label = GUICtrlCreateLabel(_NowTime(), 23, 13, 140, 50)
GUICtrlSetFont(-1, 20, -1, -1, "Arial")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)

GUISetState()
;tray menus
$info = TrayCreateItem("Crazy stats")
$about = TrayCreateItem("About the gadget")
$exit = TrayCreateItem("Close")
While 1
    $msg = TrayGetMsg()
    Switch $msg
        Case $about
            MsgBox(64, "About", "Created by i542." & @CRLF & "Skin is also created by i542" & @CRLF & "One thing I didn't create is few functions" & @CRLF & "Functions from Auto3Lib project by Paul Campbell (PaulIA). Master of these functions (he calls himself Messenger!) is lo3dn." & @CRLF & "Now also one thing I didn't created. The programming language is called AutoIt and created is by Jonnathan Bennet (spelling?) (www.autoitscript.com)" & @CRLF & "Finnaly, visit me at www.i542.net!")
        Case $exit
            ExitLoop
        Case $info
            MsgBox(64, "Crazy Stats", "You are running Alpha Clock for " & Round(TimerDiff($timer) / 1000) & " seconds." & @CRLF & "This is " & @YDAY & ". day of the year." & @CRLF & _
                    "There is " & 365 - @YDAY & " days left to the New Year" & @CRLF & "You're in " & @SEC * 1000 & ". ms")
    EndSwitch
WEnd

GUIDelete($controlGui)
;fade out png background
For $i = 255 To 0 Step - 1
    SetBitmap($GUI, $hImage, $i)
Next

; Release resources
_API_DeleteObject ($hImage)
_GDIP_Shutdown ()

; ===============================================================================================================================
; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ===============================================================================================================================
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

; ===============================================================================================================================
; SetBitMap
; ===============================================================================================================================
Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    $hScrDC = _API_GetDC (0)
    $hMemDC = _API_CreateCompatibleDC ($hScrDC)
    $hBitmap = _GDIP_BitmapCreateHBITMAPFromBitmap ($hImage)
    $hOld = _API_SelectObject ($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIP_ImageGetWidth ($hImage))
    DllStructSetData($tSize, "Y", _GDIP_ImageGetHeight ($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _API_UpdateLayeredWindow ($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _API_ReleaseDC (0, $hScrDC)
    _API_SelectObject ($hMemDC, $hOld)
    _API_DeleteObject ($hBitmap)
    _API_DeleteDC ($hMemDC)
EndFunc   ;==>SetBitmap
; I don't like AutoIt's built in ShellExec. I'd rather do the DLL call myself.
Func _ShellExecute($sCmd, $sArg = "", $sFolder = "", $rState = @SW_SHOWNORMAL)
    $aRet = DllCall("shell32.dll", "long", "ShellExecute", _
            "hwnd", 0, _
            "string", "", _
            "string", $sCmd, _
            "string", $sArg, _
            "string", $sFolder, _
            "int", $rState)
    If @error Then Return 0
    
    $RetVal = $aRet[0]
    If $RetVal > 32 Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc   ;==>_ShellExecute

Func SetTime()
    GuiCtrlSetData($Label, _NowTime())
EndFunc
I like my better, it does not need another big UDF and it won't flicker.

I can do signature me.

Link to comment
Share on other sites

Just tried it, look nice.

[u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]

Link to comment
Share on other sites

Spelling error:

MsgBox(64, "About", "Created by i542." & @CRLF & "Skin is also created by i542" & @CRLF & "One thing I didn't create is few functions" & @CRLF & "Functions from Auto3Lib project by Paul Campbell (PaulIA). Master of these functions (he calls himself Messenger!) is lo3dn." & @CRLF & "Now also one thing I didn't created. The programming language is called AutoIt and created is by Jonnathan Bennet (spelling?) (www.autoitscript.com)" & @CRLF & "Finnaly, visit me at www.i542.net!")

Is "Finally"

[u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]

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...