Jump to content

A nother Transparent


 Share

Recommended Posts

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Sleep(2000)
HotKeySet("{ESC}", "Stop")

Local $sFile = "Try.gif"
$Gui = GUICreate("test", 169, 169, @DesktopWidth - 169, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
$Pic = GUICtrlCreatePic($sFile, -1, -1, 170, 170, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetDefBkColor($GUI_BKCOLOR_TRANSPARENT)
GUISetFont(9, 400, 0, "arial")
$Lab = GUICtrlCreateLabel("", 120, 50, 150, 20)
GUISetState(@SW_SHOW)

Do
    $msg = GUIGetMsg()
    GUICtrlSetData($Lab, @SEC)
    Sleep(500)
    GUICtrlSetData($Lab, "  ¤  " & @SEC)
    Sleep(500)

    if @sec/59 = 1 then beep(1000, 10)

Until $msg = $GUI_EVENT_CLOSE

Func Stop()
    Exit 0
EndFunc   ;==>Stop

Yes I tried User32.dll and all sorts of WinAPI's but it is not getting better.

When I run this on any normal window it looks ok. BUT running on the desktop there

seems to be a white border arround the numbers. This makes it look a bit out of focus.

The other question is if one can get to run the label without having a Picture?

And another why does the picture turn white if it have less than 10% picture in it?

(If it is a Vista thing you can also say)

post-59986-12852486216732_thumb.gif

Edited by JoHanatCent
Link to comment
Share on other sites

HotKeySet("{ESC}", "Stop")

#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>

_GDIPlus_Startup()

$_Width = 150
$_Height = 200
$_Ratio = $_Width / $_Height

$sString = " Time: " & @lf & "14:00"
$hGui = GUICreate("gui", $_Width, $_Width / $_Ratio, @DesktopWidth - $_Width, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))


GUISetState(@SW_SHOW)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
$hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 10, 2)
$tLayout = _GDIPlus_RectFCreate(14, 110, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)


While 1
    Sleep(20)
WEnd


_GDIPlus_Shutdown()
Exit

Func Stop()
    Exit 0
EndFunc   ;==>Stop

Use GDI+ functions and you won't have the outline issues or have to use a picture.

Edit: Or look at the example for _WinAPI_SetLayeredWindowAttributes.

Ok tried convering it into GDIPLUS and came up with this. But it seems to stil need some immage to get atransparent window with the label showing.
Link to comment
Share on other sites

Try this:

HotKeySet("{ESC}", "Stop")

#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>

_GDIPlus_Startup()

$_Width = 150
$_Height = 200
$_Ratio = $_Width / $_Height

$sString = " Time: " & @lf & "14:00"
$hGui = GUICreate("gui", $_Width, $_Width / $_Ratio, @DesktopWidth - $_Width, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
$bg = 0x000000
GUISetBkColor($bg)
_WinAPI_SetLayeredWindowAttributes($hGui, $bg)
GUISetState(@SW_SHOW)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
$hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 10, 2)
$tLayout = _GDIPlus_RectFCreate(14, 110, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)


While Sleep(20)
WEnd
Stop()

Func Stop()
    $tLayout = 0
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    Exit
EndFunc ;==>Stop

Br,

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

By using _Timer_SetTimer(), when the text is dragged, the seconds keep ticking.

If the contents of _DisTime() function is put within the While - Wend loop with a sleep(980), then when the text is dragged the seconds freeze until the mouse button is released.

#include <Timers.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>

HotKeySet("{ESC}", "Terminate")

Local $hFont, $hFamily, $hFormat, $hBrush, $hGraphic, $hGui, $iTimer
Local $sImageOut = @TempDir & "\ModifiedImage.png"
Local $_Width = 200
Local $_Height = 100

$hGui = GUICreate("gui", $_Width, $_Height, @DesktopWidth - $_Width, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
$bg = 0x000000
GUISetBkColor($bg)
_WinAPI_SetLayeredWindowAttributes($hGui, $bg)

$iTimer = _Timer_SetTimer($hGui, 1000, "_DisTime") ; create timer
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState(@SW_SHOW)

_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
$hBrush = _GDIPlus_BrushCreateSolid(0x8000FF00)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 24, 1, 3)
$tLayout = _GDIPlus_RectFCreate(0, 0)

While Sleep(20)
WEnd


Func _DisTime($hWnd, $Msg, $iIDTimer, $dwTime)
    Local $sString = " Time: " & @LF & @HOUR & ":" & @MIN & ":" & @SEC
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    Return
EndFunc ;==>_DisTime

Func Terminate()
    $tLayout = 0
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    _Timer_KillTimer($hGui, $iTimer)
    Exit 0
EndFunc ;==>Terminate

;Enable drag text
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $hGui) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST
Link to comment
Share on other sites

  • 2 weeks later...

Thank You to all of the above.

After playing I came to this almost finished product. The rest wil be a Breeze.

Either the END or the ESC key can be used to exit.

Cheers

HotKeySet("{END}", "Stop");==>> Roep die stop funksie
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#NoTrayIcon
_GDIPlus_Startup()
$gFontSZ = 16; Just the font SiZe (Getoets van 5 tot 80)
$gWidth = $gFontSZ * 2
$gHeight = $gFontSZ + 20
$gRatio = $gWidth / $gHeight
Local $xy = 400, $yz = 300
$slaapTYD = 10
$radius = (@DesktopHeight / 2) - $gFontSZ
$x = (@DesktopWidth / 2) - $gFontSZ
$y = (@DesktopHeight / 2) - $gFontSZ

$bg = 0xFF000000 ;0x000000 is Deursigtige AgterGrond Kleur probeer bietjie 0xFF00007F
$sString = ""
$minuut = @MIN
$hGui = GUICreate("gui", $gWidth, $gWidth / $gRatio, @DesktopWidth - $gWidth, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))

GUISetBkColor($bg)
_WinAPI_SetLayeredWindowAttributes($hGui, $bg)

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
$hBrush = _GDIPlus_BrushCreateSolid(0xFF00000F);0xFF000000   0xFF00007F
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, $gFontSZ, 2)
$tLayout = _GDIPlus_RectFCreate(-1, -1, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
$TekeN = _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    If $Msg = -3 Then ExitLoop; Kan ook EXIT van hier
    If $sString <> @SEC Then
        $sString = @SEC
        $degree = $sString * 6 - 90
        $radian = ($degree / 180) * 3.14159265358979
        $xz = $x + Cos($radian) * $radius
        $yz = $y + Sin($radian) * $radius
        $sString = Number(@SEC)
        _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)
        $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
        _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
        WinMove("gui", "", $xz, $yz)
        Sleep($slaapTYD)
        If @SEC = 0 Then Bleeper()
    EndIf
    Sleep($slaapTYD)
WEnd
Stop();==>>  Kom net hier uit as exitloop van die While loop
Func Bleeper();==> Keep awake
    Beep(500, 20)
    Sleep($slaapTYD)
if @min = 30 Then Beep(900, 200)
if @min = 0 Then Beep(1000, 400)
EndFunc   ;==>Bleeper
Func Stop(); Eindig program onmiddelik of End of Escape
    $tLayout = 0
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>Stop
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...