Jump to content

---


playlet
 Share

Recommended Posts

Because of the great way you coded this, there are several places you can use Assign in place of a large Switch statement. Reading code with Assign isn't as easy as the way you had it, but it is shorter. I left both sections of code in for you to choose.

One bug I did find was when you go to close a maximized window, the toolbar pops up.

Also, if you go to minimize a maximized window, the toolbar pops up. Then you click on minimize and the window minimizes. Then, once you move the mouse away from the right side of the screen, the toolbar hides itself (which is fine). But then WinActivate restores the minimized window so you can't ever minimize a maximized window. It will always be restored.

I fixed these minor problems by changing the if statement on line 140. I also found that editing the while() part of the loop on line 154 provided better results as far as not hiding the gui when it shouldn't be hidden.

Your launcher is looking great and has a bright future.

Edited by dantay9
Link to comment
Share on other sites

  • Replies 338
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

I am waiting for a reply to a bit of trouble I have been having with context menus. Tried for several days and still nothing. I needed a break and your program was very interesting. I edited your script a bit to make it shorter and also a bit lighter on the cpu. See anything you like?

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Au3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Tidy=y
#Tidy_Parameters=/sfc
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

#Region Setup
If _Singleton(@ScriptName, 1) = 0 Then
    MsgBox(0, "Warning", "You can only start this application once!")
    Exit (1)
EndIf

If Not FileExists(@TempDir & "\essential2\") Then DirCreate(@TempDir & "\essential2\")
FileInstall("devilish.ico", @TempDir & "\essential2\devilish.ico", 1)
FileInstall("normal.png", @TempDir & "\essential2\normal.png", 1)
FileInstall("over.png", @TempDir & "\essential2\over.png", 1)
FileInstall("pressed.png", @TempDir & "\essential2\pressed.png", 1)
;~ FileInstall("normal-small.png", @TempDir & "\essential2\normal-small.png", 1)
;~ FileInstall("over-small.png", @TempDir & "\essential2\over-small.png", 1)
;~ FileInstall("pressed-small.png", @TempDir & "\essential2\pressed-small.png", 1)
FileInstall("normal-exit.png", @TempDir & "\essential2\normal-exit.png", 1)
FileInstall("over-exit.png", @TempDir & "\essential2\over-exit.png", 1)
FileInstall("pressed-exit.png", @TempDir & "\essential2\pressed-exit.png", 1)

_GDIPlus_Startup()
TraySetIcon(@TempDir & "\essential2\devilish.ico")
Opt("TrayAutoPause", 0)
#EndRegion Setup

Global Const $NormalImage = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential2\normal.png")
Global Const $OverImage = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential2\over.png")
Global Const $PressedImage = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential2\pressed.png")
;~ Global Const $NormalImage_Small = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential2\normal-small.png")
;~ Global Const $OverImage_Small = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential2\over-small.png")
;~ Global Const $PressedImage_Small = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential2\pressed-small.png")
Global Const $NormalImage_Small = _ResizeBitmap(@TempDir & "\essential2\normal.png", 118, 53)
Global Const $OverImage_Small = _ResizeBitmap(@TempDir & "\essential2\over.png", 118, 53)
Global Const $PressedImage_Small = _ResizeBitmap(@TempDir & "\essential2\pressed.png", 118, 53)
Global Const $NormalImage_Exit = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential2\normal-exit.png")
Global Const $OverImage_Exit = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential2\over-exit.png")
Global Const $PressedImage_Exit = _GDIPlus_ImageLoadFromFile(@TempDir & "\essential2\pressed-exit.png")
Global Const $WS_EX_COMPOSITED = 0x2000000
Global Const $AC_SRC_ALPHA = 1
Global Const $Sensitivity = 75
Global Const $Width = 167
Global Const $Height = 490
Global $PosX = @DesktopWidth - 163
Global $PosY = @DesktopHeight - 520
Global $Pause = 0
Global $LastActiveWindow = ""
Global $Offline = 1
Dim $LabelArray[14][2]
Dim $Over[12]
Dim $Pressed[12]

;Internet Status Area
LoadNetChecking()

#Region Image GUI
$GUI = GUICreate("Launcher-Playlet", $Width, $Height, $PosX, $PosY, $WS_POPUP, $WS_EX_LAYERED, WinGetHandle("[CLASS:Progman]"))
GUISetIcon(@TempDir & "\essential2\devilish.ico")
GUISetState(@SW_SHOW, $GUI)

;Skin Creation Area
$Skin = _ImageDraw()
For $i = 1 To 11
    $Over[$i] = _ImageDraw("over", $i)
    $Pressed[$i] = _ImageDraw("pressed", $i)
Next
#EndRegion Image GUI

#Region GUI for holding button text, also for getting hover position
$ControlGUI = GUICreate("ControlGUI", $Width, $Height, $PosX, $PosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED), $GUI)
GUISetFont(14, 400, -1, "Comic Sans MS")
GUISetBkColor(0x123456, $ControlGUI)

;Control Creation Area
$LabelArray[1][0] = GUICtrlCreateLabel("Button 1", 12, 9, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray[2][0] = GUICtrlCreateLabel("Button 2", 12, 50, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray[3][0] = GUICtrlCreateLabel("Button 3", 12, 91, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray[4][0] = GUICtrlCreateLabel("Button 4", 12, 132, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray[5][0] = GUICtrlCreateLabel("Button 5", 12, 173, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray[6][0] = GUICtrlCreateLabel("Button 6", 12, 214, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray[7][0] = GUICtrlCreateLabel("Button 7", 12, 255, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray[8][0] = GUICtrlCreateLabel("Button 8", 12, 296, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray[9][0] = GUICtrlCreateLabel("Button 9", 12, 337, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray[10][0] = GUICtrlCreateLabel("Button 10", 12, 378, 144, 36, BitOR($SS_CENTER, $SS_CENTERIMAGE))
$LabelArray[11][0] = GUICtrlCreateLabel("", 116, 419, 40, 36);Exit Label

$LabelArray[12][0] = GUICtrlCreateLabel("", 19, 424, 87, 13, BitOR($SS_CENTER, $SS_CENTERIMAGE));Status Label
GUICtrlSetFont(-1, 8)
$LabelArray[13][0] = GUICtrlCreateLabel("", 19, 436, 87, 13, BitOR($SS_CENTER, $SS_CENTERIMAGE));Usage Label
GUICtrlSetFont(-1, 8)

For $i = 1 To 13
    GUICtrlSetBkColor($LabelArray[$i][0], $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor($LabelArray[$i][0], 0xFFFFFF)
Next

_API_SetLayeredWindowAttributes($ControlGUI, 0x123456, 230)
GUISetState(@SW_SHOW, $ControlGUI)
#EndRegion GUI for holding button text, also for getting hover position

;Set State Variable
For $i = 1 To 11
    $LabelArray[$i][1] = 0 ;normal = 0; over = 1; pressed = 2; pressed, but not over on mouseup = 3
Next

;Setup Main Skin
SetBitmap($GUI, $Skin, 255)

While 1
    $MousePos = MouseGetPos()
    If $MousePos[0] > @DesktopWidth - $Sensitivity And $MousePos[1] > 40 Then
        $GUIWinPos = WinGetPos($GUI)

        If $GUIWinPos[0] <> $PosX Then ;window is hidden
            $LastActiveWindow = WinGetTitle("[active]")
            GUISetState(@SW_SHOW, $GUI)

            For $i = @DesktopWidth To $PosX Step -10 ;slide in window
                WinMove($GUI, "", $i, $PosY)
                WinMove($ControlGUI, "", $i, $PosY)
                Sleep(10)
            Next
            WinMove($GUI, "", $PosX, $PosY)
            WinMove($ControlGUI, "", $PosX, $PosY)
        Else ;window is shown
            $CursorInfo = GUIGetCursorInfo($ControlGUI)

            ;While(mouse is close enought to right edge of screen) Or (mouse is over gui)
            While ($MousePos[0] > @DesktopWidth - $Sensitivity) Or ($MousePos[0] > $PosX And $MousePos[1] > $PosY And $MousePos[1] < $PosY + $Height)
                $MousePos = MouseGetPos()
                $CursorInfo = GUIGetCursorInfo($ControlGUI)

                #Region Button Checking Part
                For $i = 1 To 11
                    If $CursorInfo[4] = $LabelArray[$i][0] Then ;cursor is over button
                        While $CursorInfo[4] = $LabelArray[$i][0] ;while cursor is over button
                            $CursorInfo = GUIGetCursorInfo($ControlGUI)
                            Switch $CursorInfo[2]
                                Case 0 ;if button isn't pressed
                                    If $LabelArray[$i][1] <> 1 Then
                                        $LabelArray[$i][1] = 1 ;state = over
                                        SetBitmap($GUI, $Over[$i], 255)
                                    EndIf
                                Case 1 ;if button is pressed
                                    If $LabelArray[$i][1] <> 2 Then
                                        $LabelArray[$i][1] = 2 ;state = pressed
                                        SetBitmap($GUI, $Pressed[$i], 255)
                                    EndIf

                                    While $CursorInfo[2] = 1
                                        $CursorInfo = GUIGetCursorInfo($ControlGUI)

                                        If $CursorInfo[4] = $LabelArray[$i][0] Then ;if button is pressed and is over the control
                                            If $LabelArray[$i][1] <> 2 Then
                                                $LabelArray[$i][1] = 2 ;state = pressed
                                                SetBitmap($GUI, $Pressed[$i], 255)
                                            EndIf
                                        Else ;if button is pressed and is not over the control
                                            If $LabelArray[$i][1] <> 3 Then
                                                $LabelArray[$i][1] = 3 ;state = pressed and over
                                                SetBitmap($GUI, $Over[$i], 255)
                                            EndIf
                                        EndIf
                                        Sleep(10)
                                    WEnd

                                    If $CursorInfo[4] = $LabelArray[$i][0] Then RunButton($i)
                            EndSwitch
                            Sleep(10)
                        WEnd

                        $LabelArray[$i][1] = 0 ;set state to normal
                        SetBitmap($GUI, $Skin, 255) ;reset all buttons
                    Else
                        GetNetStatus() ;Update status fields when not over the control - reduces usage
                    EndIf
                Next
                #EndRegion Button Checking Part

                Sleep(10) ;can be changed depending on cpu speed
            WEnd
        EndIf
    Else
        $GUIWinPos = WinGetPos($GUI)
        If $GUIWinPos[0] <> @DesktopWidth Then
            For $i = $PosX To @DesktopWidth Step 10
                WinMove($GUI, "", $i, $PosY)
                WinMove($ControlGUI, "", $i, $PosY)
                Sleep(10)
            Next
            WinMove($GUI, "", @DesktopWidth, $PosY)
            WinMove($ControlGUI, "", @DesktopWidth, $PosY)

            GUISetState(@SW_HIDE, $GUI)
            If $LastActiveWindow <> "" Then WinActivate($LastActiveWindow)
        EndIf
    EndIf
    Sleep(20)
WEnd

Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False)
    Local Const $AC_SRC_ALPHA = 1
    Local Const $ULW_ALPHA = 2
    Local Const $LWA_ALPHA = 0x2
    Local Const $LWA_COLORKEY = 0x1
    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA)
    If @error Then
        Return SetError(@error, 0, 0)
    ElseIf $Ret[0] = 0 Then
        Return SetError(4, 0, 0)
    Else
        Return 1
    EndIf
EndFunc ;==>_API_SetLayeredWindowAttributes

Func _ResizeBitmap($sFile, $newW, $newH)
    Local $oldImage, $GC, $newBmp, $newGC

    ; Load Image
    $oldImage = _GDIPlus_ImageLoadFromFile($sFile)

    ;Create New image
    $GC = _GDIPlus_ImageGetGraphicsContext($oldImage)
    $newBmp = _GDIPlus_BitmapCreateFromGraphics($newW, $newH, $GC)
    $newGC = _GDIPlus_ImageGetGraphicsContext($newBmp)

    ;Draw
    _GDIPlus_GraphicsDrawImageRect($newGC, $oldImage, 0, 0, $newW, $newH)

    ;Clenaup
    _GDIPlus_GraphicsDispose($GC)
    _GDIPlus_GraphicsDispose($newGC)
    _GDIPlus_ImageDispose($oldImage)
    Return $newBmp
EndFunc ;==>_ResizeBitmap

Func GetNetStatus()
    Global $tRASCONN, $iCntByte, $iCntConn, $tRAS_STATS
    If @IPAddress1 <> "127.0.0.1" Then
        If $Offline = 1 Then
            $aRet = DllCall("rasapi32.dll", "int", "RasEnumConnections", "ptr", DllStructGetPtr($tRASCONN), "ptr", DllStructGetPtr($iCntByte), "ptr", DllStructGetPtr($iCntConn))
            If $aRet[0] Then SetError(2, $aRet[0], -1)
            If DllStructGetData($iCntConn, 1) < 1 Then SetError(1, 0, 0) ;Error: not opened connections
            $Offline = 0
            GUICtrlSetData($LabelArray[12][0], "Online (0')")
            GUICtrlSetData($LabelArray[13][0], "Usage: 0.00 mb")
        EndIf
        $aRet = DllCall("rasapi32.dll", "int", "RasGetConnectionStatistics", "hwnd", DllStructGetData($tRASCONN, "hRasConn"), "ptr", DllStructGetPtr($tRAS_STATS))
        If $aRet[0] Then SetError(3, $aRet[0], -1)
        $stat = DllStructGetData($tRAS_STATS, "dwBytesXmited")
        $stat2 = DllStructGetData($tRAS_STATS, "dwBytesRcved")
        $stat3 = DllStructGetData($tRAS_STATS, "dwConnectDuration")
        $sentmb = Round(($stat / 1048576), 2)
        $receivedmb = Round(($stat2 / 1048576), 2)
        $totalsummb = Round((($stat + $stat2) / 1048576), 2)
        $time = Round((($stat3 / 1000) / 60), 2)
        $split = StringSplit($time, ".")
        $min = $split[1]
        $read = GUICtrlRead($LabelArray[12][0])
        $read2 = GUICtrlRead($LabelArray[13][0])
        $splitter = StringSplit($read, "Online (", 1)
        $splitter2 = StringSplit($splitter[2], "')", 1)
        $accmin = $splitter2[1]
        $splitter3 = StringSplit($read2, "Usage: ", 1)
        $splitter4 = StringSplit($splitter3[2], " mb", 1)
        $accmb = $splitter4[1]
        If $min <> $accmin Or $totalsummb <> $accmb Then
            If ($totalsummb - $accmb) >= 0.125 Then ;update every ~125 kb
                GUICtrlSetData($LabelArray[12][0], "Online (" & $min & "')")
                GUICtrlSetData($LabelArray[13][0], "Usage: " & $totalsummb & " mb")
            ElseIf $min <> $accmin Then
                GUICtrlSetData($LabelArray[12][0], "Online (" & $min & "')")
            EndIf
        EndIf
    Else
        $readoff = GUICtrlRead($LabelArray[12][0])
        $readoff2 = GUICtrlRead($LabelArray[13][0])
        If $readoff <> "Offline" Or $readoff = "" Then
            GUICtrlSetData($LabelArray[12][0], "Offline")
            GUICtrlSetData($LabelArray[13][0], "Usage: -")
            $Offline = 1
        EndIf
    EndIf
EndFunc ;==>GetNetStatus


Func LoadNetChecking()
    Global Const $MAX_PATH = 260
    Global Const $RAS_MaxDeviceType = 16
    Global Const $RAS_MaxEntryName = 256
    Global Const $RAS_MaxDeviceName = 128
    Global $tRASCONN = DllStructCreate("dword dwSize;hwnd hRasConn;char szEntryName[" & $RAS_MaxEntryName + 1 & "];" & "char szDeviceType[" & $RAS_MaxDeviceType + 1 & "];" _
             & "char szDeviceName[" & $RAS_MaxDeviceName + 1 & "];" & "char szPhonebook[" & $MAX_PATH & "];" & "dword dwSubEntry;byte guidEntry[16];dword dwFlags;byte luid[8]")
    Global $tRAS_STATS = DllStructCreate("dword dwSize;dword dwBytesXmited;dword dwBytesRcved;dword dwFramesXmited;" & _
            "dword dwFramesRcved;dword dwCrcErr;dword dwTimeoutErr;dword dwAlignmentErr;" & "dword dwHardwareOverrunErr;dword dwFramingErr;dword dwBufferOverrunErr;" & _
            "dword dwCompressionRatioIn;dword dwCompressionRatioOut;dword dwBps;dword dwConnectDuration")
    Global $iCntByte = DllStructCreate("dword")
    Global $iCntConn = DllStructCreate("dword")
    DllStructSetData($iCntByte, 1, DllStructGetSize($tRASCONN))
    DllStructSetData($tRASCONN, "dwSize", DllStructGetSize($tRASCONN))
    DllStructSetData($tRAS_STATS, "dwSize", DllStructGetSize($tRAS_STATS))
EndFunc ;==>LoadNetChecking

Func OnAutoItExit()
    If IsDeclared("WS_EX_COMPOSITED") Then ;if script wasn't closed by _Singleton
        _GDIPlus_ImageDispose($NormalImage)
        _GDIPlus_ImageDispose($NormalImage_Small)
        _GDIPlus_ImageDispose($NormalImage_Exit)
        _GDIPlus_ImageDispose($OverImage)
        _GDIPlus_ImageDispose($OverImage_Small)
        _GDIPlus_ImageDispose($OverImage_Exit)
        _GDIPlus_ImageDispose($PressedImage)
        _GDIPlus_ImageDispose($PressedImage_Small)
        _GDIPlus_ImageDispose($PressedImage_Exit)
        _GDIPlus_Shutdown()

        WinActivate($LastActiveWindow)
        DirRemove(@TempDir & "\essential2", 1)

        Beep(1000, 50)
        Beep(2000, 50)
        Beep(500, 50)
    EndIf
EndFunc ;==>OnAutoItExit

Func RunButton($ButtonNumber)
    Switch $ButtonNumber
        Case 1 To 10
            Beep(1000, 50)
            Beep(2000, 50)

            MsgBox(0, "", "You Pressed Button " & $ButtonNumber)
        Case 11
            Exit
    EndSwitch
EndFunc ;==>RunButton

Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc ;==>SetBitmap

Func _ImageDraw($State = "normal", $Case = ""); draw a picture on to png
    Local $hGraphic1, $hBitmap, $hGraphic2
    Local $Image[13]

    ;set up defaults
    For $i = 1 To 10
        $Image[$i] = $NormalImage
    Next
    $Image[11] = $NormalImage_Small
    $Image[12] = $NormalImage_Exit

    ;Create a new bitmap, this way the original opened png is left unchanged
    $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphic1)
    $hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    ; Draw the original opened png into my newly created bitmap
    Switch $State
        Case "normal"
        Case "pressed"
            Switch $Case
                Case 1 To 10
                    $Image[$Case] = $PressedImage
                Case 11
                    $Image[12] = $PressedImage_Exit
            EndSwitch
        Case "over"
            Switch $Case
                Case 1 To 10
                    $Image[$Case] = $OverImage
                Case 11
                    $Image[12] = $OverImage_Exit
            EndSwitch
    EndSwitch

    For $i = 1 To 10
        _GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[$i], 0, ($i - 1) * 41, 167, 57)
    Next
    _GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[11], 3, 411, 118, 53)
    _GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[12], 107, 412, 57, 52)

    ;Cleanup the no longer needed resources
    _GDIPlus_GraphicsDispose($hGraphic2)
    _GDIPlus_GraphicsDispose($hGraphic1)

    ;Return the new bitmap
    Return $hBitmap
EndFunc ;==>_ImageDraw
Link to comment
Share on other sites

Hi

Doesn't matter to me if you want to you use trans text or not but wanted to ensure you were clear what I meant and so included a picture.

Icon and text on the button instead of the way you have it with just text. Just an idea.

Dantay9 that was a nice piece of code you put in the _ImageDraw function I'll need to study it.

post-45064-12596106011137_thumb.jpg

Link to comment
Share on other sites

@playlet

I really like how you used GUIGetCursorInfo. When I made your script smaller, I just left that pretty much the same. That must have taken a while to get it just right.

Assign can be used when elements aren't in an array (in my script I put them in an array). For example:

in your script you have $over1, $over2, $over3... There are two options to make this easy. You can either put the variables in an array:

For $i = 1 To 11
    $Over[$i] = _ImageDraw("over", $i)
Next

Or you can use Assign like this:

For $i = 1 To 11
    Assign("over" & $i, _ImageDraw("over", $i))
Next

The array is what most people use, but I made this post before I decided to have a little fun with playlet's launcher.

@picea892

That _ImageDraw function was all playlet. I just made it a bit shorter. It does exactly the same thing as before. Normally, when I do toolbars and stuff like that, I make each button separately. But I like how the buttons are actually just a picture. That saves on having to redraw buttons. Great job playlet.

Edited by dantay9
Link to comment
Share on other sites

Fast smooth and compact, great stuff guys, 5 * from me

I noticed 1 small prob with it: when active, it will not let you adjust your sound volume from the tray anymore,

at least, not thru the left click / slider method (XP SP2, 1680x1050) It seems that the small slider does not 'inherit' the

on top state from the taskbar, so one could argue it's M$'s fault ... Other tray stuff, like the Launcher's tray

menu, does not trigger this.

Easily cured of course, with $Sensitivity = 25 i.o. 75

cheers,

whim

Link to comment
Share on other sites

Can't scroll with a maximized window (such as Firefox) because the scrollbar is on the right hand side by the toolbar. I added a little wait time to make sure the user really does want to activate the toolbar. This time can be changed as needed.

The first part of the if statement on line 123 can be changed to this:

If $GUIWinPos[0] <> $PosX Then ;window is hidden
 $Timer = TimerInit()
 ;wait 500 ms to see if mouse is just passing through the zone and mouse isn't clicked (in case scroll bar is in use)
 ;the 500 ms wait time can be changed depending on preference
 While $MousePos[0] > @DesktopWidth - $Sensitivity And $MousePos[1] > 40 And TimerDiff($Timer) < 500 And Not _IsPressed("01")
 $MousePos = MouseGetPos()
 Sleep(20)
 WEnd
 $Timer = 0 ;release timer
 If $MousePos[0] > @DesktopWidth - $Sensitivity And $MousePos[1] > 40 And Not _IsPressed("01") Then

$LastActiveWindow = WinGetTitle("[active]")
GUISetState(@SW_SHOW, $GUI)
Edited by dantay9
Link to comment
Share on other sites

Icon and text on the button instead of the way you have it with just text.

Are you saying to draw each button separately and have the text on the button? If you want to draw text on a png, here is a bit of code from my web browser:

Func _ImageDrawText($hImage, $sText, $iX = 0, $iY = 0, $iRGB = 0x000000, $iSize = 9, $iStyle = 0, $sFont = "Arial")
    Local $w, $h, $hGraphic1, $hBitmap, $hGraphic2, $Hbrush, $hFormat, $hFamily, $hFont, $tLayout, $aInfo
    $w = _GDIPlus_ImageGetWidth($hImage)
    $h = _GDIPlus_ImageGetHeight($hImage)

    ;Create a new bitmap, this way the original opened png is left unchanged
    $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($w, $h, $hGraphic1)
    $hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    ; Draw the original opened png into my newly created bitmap
    _GDIPlus_GraphicsDrawImageRect($hGraphic2, $hImage, 0, 0, $w, $h)

    ;Create the font
    $Hbrush = _GDIPlus_BrushCreateSolid("0xFF" & Hex($iRGB, 6))
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    $hFont = _GDIPlus_FontCreate($hFamily, $iSize, $iStyle)
    $tLayout = _GDIPlus_RectFCreate($iX, $iY, 0, 0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic2, $sText, $hFont, $tLayout, $hFormat)

    ;Draw the font onto the new bitmap
    _GDIPlus_GraphicsDrawStringEx($hGraphic2, $sText, $hFont, $aInfo[0], $hFormat, $Hbrush)

    ;Cleanup the no longer needed resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($Hbrush)
    _GDIPlus_GraphicsDispose($hGraphic2)
    _GDIPlus_GraphicsDispose($hGraphic1)

    ;Return the new bitmap
    Return $hBitmap
EndFunc ;==>_ImageDrawText
Link to comment
Share on other sites

Yes, that's the way to go. Draw it right on the png and then you won't have a conflict with the guictrllabel receiving the click for the entire area. I think it's the cleanest way to go.

Your code will work great, just have to change

_GDIPlus_GraphicsDrawStringEx($hGraphic2, $sText, $hFont, $aInfo[0], $hFormat, $Hbrush)

to a _GDIPlus_GraphicsDrawImageRect(

Edit: Well it might be a bit more complicated than that, would need to extract icon from exe and change icon to a bmp first. I've never done it before and might be difficult.

Edited by picea892
Link to comment
Share on other sites

  • 2 weeks later...

Hey Playlet, do you have any plans of adding a gui to set options for the launcher and allow the buttons' actions to be customized? Your launcher already has the looks, it just needs some functionality added to it (like several of my projects). This is a great setup and I would love to see this project go all the way.

Edited by dantay9
Link to comment
Share on other sites

  • 2 weeks later...

Been out of town for Christmas the past three days so I wasn't on the forum.

I have to say this is turning out to be great! I love it. I think it would be easier to use drag and drop onto the button itself to change the executing program instead of bringing up the settings screen. This suggestion is purely based on taste and is up to you whether or not you think it would make a positive impact on the program.

Edited by dantay9
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...