Jump to content

---


playlet
 Share

Recommended Posts

  • Replies 338
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

New AutoIt has this included.

..... Might help if I update AutoIT!!! Lol! It now works like a charm! ;) Cool, a drag and drop feature!

Here is something you might want to try, I have set mine up just the way I like it but I have left over blank buttons. Maybe insert in a function that allows you to remove any unused buttons?

Once again very nice!

Link to comment
Share on other sites

Very nice Playlet.

Congratulations, I've added my 5 star.

One suggestion. You probably should stick to a standard icon size of 16 or 32. The icon will be sharper. I added autoit related exes and when I changed this line the results were remarkable.

$hIcon[$i] = _Icons_Icon_Extract($ifile[$i], 0, 32, 32)

Once again, excellent work, I think you've got the best launcher on the forum

Edited by picea892
Link to comment
Share on other sites

If you are looking for a fairly complete way to extract the icon from a file, my RocketDock (in my sig) has the ability. Here is the bulk of the icon functions. I might have missed a few specific situations, but, for me, this works for almost all files.

Func RetrieveIconPath($sPath)
    Local $Reg, $defaultBrowser, $Short
    $Reg = StringRegExp($sPath, "(?<Protocol>\w+):\/\/(?<Domain>[\w@][\w.:@]+)\/?[\w\.?=%&=\-@/$,]*", 3)
    If (IsArray($Reg) And UBound($Reg) = 2 And ($Reg[0] = "http" Or $Reg[0] = "https")) Or StringLeft($sPath, 4) = "www." Then
        $defaultBrowser = RegRead("HKEY_CLASSES_ROOT\http\shell\open\command", "")
        $defaultBrowser = StringTrimLeft($defaultBrowser, 1)
        $defaultBrowser = StringMid($defaultBrowser, 1, StringInStr($defaultBrowser, '"') - 1)
        $Reg = _GetRegDefIcon($defaultBrowser)
        Return SetError(0, 1, $Reg)
    ElseIf StringRight($sPath, 4) = ".lnk" Then
        $Short = FileGetShortcut($sPath)
        $Reg = _GetRegDefIcon($Short[0])
        Return SetError(0, 2, $Reg)
    Else
        $Reg = _GetRegDefIcon($sPath)
        Return SetError(0, 3, $Reg)
    EndIf
    Return SetError(-1, -1, -1)
EndFunc ;==>RetrieveIconPath


Func _GetRegDefIcon($Path)
    Local $FileName, $Count, $Name, $Ext, $Curver, $DefaultIcon, $Ret[2] = [$DF_NAME, $DF_INDEX]

    $FileName = StringTrimLeft($Path, StringInStr($Path, '\', 0, -1))
    $Count = StringInStr($FileName, '.', 0, -1)
    If $Count > 0 Then
        $Count = StringLen($FileName) - $Count + 1
    EndIf
    $Name = StringStripWS(StringTrimRight($FileName, $Count), 3)
    $Ext = StringStripWS(StringRight($FileName, $Count - 1), 8)
    If StringLen($Ext) = 0 Then
        Return $Ret
    EndIf
    $Curver = StringStripWS(RegRead('HKCR\' & RegRead('HKCR\' & '.' & $Ext, '') & '\CurVer', ''), 3)
    If (@error) Or (StringLen($Curver) = 0) Then
        $DefaultIcon = _WinAPI_ExpandEnvironmentStrings(StringReplace(RegRead('HKCR\' & RegRead('HKCR\' & '.' & $Ext, '') & '\DefaultIcon', ''), '''', ''))
    Else
        $DefaultIcon = _WinAPI_ExpandEnvironmentStrings(StringReplace(RegRead('HKCR\' & $Curver & '\DefaultIcon', ''), '''', ''))
    EndIf
    $Count = StringInStr($DefaultIcon, ',', 0, -1)
    If $Count > 0 Then
        $Count = StringLen($DefaultIcon) - $Count
        $Ret[0] = StringStripWS(StringTrimRight($DefaultIcon, $Count + 1), 3)
        If $Count > 0 Then
            $Ret[1] = StringStripWS(StringRight($DefaultIcon, $Count), 8)
        EndIf
    Else
        $Ret[0] = StringStripWS(StringTrimRight($DefaultIcon, $Count), 3)
    EndIf
    If StringLeft($Ret[0], 1) = '%' Then
        $Count = DllCall('shell32.dll', 'int', 'ExtractIcon', 'int', 0, 'str', $Path, 'int', -1)
        If $Count[0] = 0 Then
            $Ret[0] = $DF_NAME
            If StringLower($Ext) = 'exe' Then
                $Ret[1] = 2
            Else
                $Ret[1] = 0
            EndIf
        Else
            $Ret[0] = StringStripWS($Path, 3)
            $Ret[1] = 0
        EndIf
    Else
        If (StringLen($Ret[0]) > 0) And (StringInStr($Ret[0], '\', 0) = 0) Then
            $Ret[0] = @SystemDir & '\' & $Ret[0]
        EndIf
    EndIf
    If Not FileExists($Ret[0]) Then
        $Ret[0] = $DF_NAME
        $Ret[1] = $DF_INDEX
    EndIf
    ; if $ret[1] < 0 then
    ;   $ret[1] = - $ret[1]
    ; else
    ;   $ret[1] = - $ret[1] - 1
    ; endif
    Return $Ret
EndFunc ;==>_GetRegDefIcon
Link to comment
Share on other sites

Hi Playlet

Tired of this script yet? I'm sure you've worked more than enough on it and I certainly understand if you are happy to move on from this example. But if you are still looking for suggestions.....

1) When the link is a folder, an improper icon appears. You should put in a if link is folder (4th to last character is not a ".") then use windows explorer icon

2) Second thought, I have a dual screen setup with my primary monitor on the left. So when your gui moves off the screen to the right....I can see it on my second monitor. Perhaps you would consider adding a guihide or something similar to address.

3) Up for a challenge? A cool advancement would be able to have behave similar to the taskbar. You could drag the GUI and it would snap to the nearest screen edge. So you could have it on the top, left right or bottom. Perhaps more work and time than you want to invest.....I half think it would require almost a rewrite....so maybe forget I suggested :D

4) Right click menu. Not sure if you have windows 7 or not, but could have pinned documents for the right click similar to that functionality. So say the link is internet explorer. You could add facebook, google etc. as pinned items that can be accessed when you right click...

Just thoughts nothing more...feel free to ignore.

Picea

Edited by picea892
Link to comment
Share on other sites

Good luck to you...that would be pretty neat.

I guess it is called a "jumplist". I included a picture from the microsoft website. You can add to the jumplist by dragging and dropping a file on the tasbkar button. There are probably other ways. I'm really not the right person to talk about windows 7 functionality....I know about it only from trying other people's computers.

Picea

post-45064-12639178685298_thumb.jpg

Link to comment
Share on other sites

I know how hard it is doing homework and stuff in high school, I bet college is a lot harder because you only have class every other day, so I decided to help you out. I already had a pretty good idea on how to docking to the sides (and I thought it would be fun). I have added the ability to switch the sides of the dock and split up some of the repetitive code into functions. Sorry if I changed too much. I will try to stay out of the code a bit more (but it is just so tempting!). I created this functionality separately, so if I missed adding in a piece of your code, please add it back in.

I love the ideas that are coming upon this project. I wish some of my programs had developed this far. One thing I did find, but couldn't fix (at least not quickly). In config mode, when dragging a file onto a button, the droppable target is not the whole label like I believe you wanted. The droppable target has shrunk to just the actual pixels that contain the letters "Drop Here". I am not sure, but I think it has something to do with the $WS_EX_LAYERED attribute of the window. That is something that needs attention.

Edit: There is also a memory leak. I fixed part of it (because it was my fault), but a small one has still managed to outwit me. I can't find it, but since it is not very big, it shouldn't be of great priority.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=devilish.ico
#AutoIt3Wrapper_Outfile=Playlet's Launcher 3.7.5.5.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Description=Launcher by Playlet
#AutoIt3Wrapper_Res_Fileversion=3.7.5.5
#AutoIt3Wrapper_Au3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Tidy=y
#Tidy_Parameters=/sfc
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

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

#include <Constants.au3>
#include <Misc.au3>
#include <GDIPlus.au3>
#include <GDIPlusConstants.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Opt("TrayAutoPause", 0)
OnAutoItExitRegister("CleanUpOnExit")

If Not FileExists(@TempDir & "\PL-essential\") Then DirCreate(@TempDir & "\PL-essential\")
FileInstall("state_icons.icl", @TempDir & "\PL-essential\state_icons.icl", 1)
TraySetIcon(@TempDir & "\PL-essential\state_icons.icl", 1)
FileInstall("normal.png", @TempDir & "\PL-essential\normal.png", 1)
FileInstall("over.png", @TempDir & "\PL-essential\over.png", 1)
FileInstall("pressed.png", @TempDir & "\PL-essential\pressed.png", 1)
FileInstall("normal-exit.png", @TempDir & "\PL-essential\normal-exit.png", 1)
FileInstall("over-exit.png", @TempDir & "\PL-essential\over-exit.png", 1)
FileInstall("pressed-exit.png", @TempDir & "\PL-essential\pressed-exit.png", 1)
FileInstall("Poof.png", @TempDir & "\PL-essential\Poof.png", 1)

; internet status area
LoadNetChecking()

_GDIPlus_Startup()
Global Const $NormalImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\normal.png")
Global Const $OverImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\over.png")
Global Const $PressedImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\pressed.png")
Global Const $NormalImage_Small = _ResizeBitmap(@ScriptDir & "\normal.png", 118, 53)
Global Const $NormalImage_Exit = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\normal-exit.png")
Global Const $OverImage_Exit = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\over-exit.png")
Global Const $PressedImage_Exit = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\pressed-exit.png")

Global Const $__SS_BITMAP = 0x0E, $__SS_ICON = 0x03, $__STM_SETIMAGE = 0x0172, $__STM_GETIMAGE = 0x0173
Global Const $WM_EXITSIZEMOVE = 0x232

Global Const $IniFile = @ScriptDir & "\Config.ini"
Global Const $Width = 167, $Height = 490

Global $SetupGUI, $ButtonSave, $tRASCONN, $iCntByte, $iCntConn, $tRAS_STATS, $NetTimer
Global $LastActiveWindow = "", $Offline = 1, $TimerInitiated = 0, $FirstNetCheckup = 1, $LastTotalSumMB = 0, $LastTime = 0
Global $PosX = @DesktopWidth - 163, $PosY = @DesktopHeight - 520 ;GUI position when exposed
Global $Icon[11], $TextArray[13], $Over[12], $Pressed[12], $PositionArray[14][2]
Global $Input[11], $LabelText[11], $RunProgram[12]

#Region You Might Need To Modify These Constants
Global $Sensitivity = 5 ;show - hide parameters
Global $Side = "Right", $GUIState = "Shown"
Global Const $IconSize = 24, $IconPosition = 7 ;icon size and position - use this if you want smaller icons
;Global Const $icon_size = 32, $icon_position = 3; icon size and position - use this if you want larger, sharper icons
#EndRegion You Might Need To Modify These Constants

#Region Create Bitmap Resources
$MainSkin = _ImageDraw()
For $i = 1 To 11
    $Over[$i] = _ImageDraw("over", $i)
    $Pressed[$i] = _ImageDraw("pressed", $i)
Next
$ConfigSkin = _ImageDraw("config")
#EndRegion Create Bitmap Resources

#Region Dispose of Unused Handles
_GDIPlus_ImageDispose($NormalImage)
_GDIPlus_ImageDispose($OverImage)
_GDIPlus_ImageDispose($PressedImage)
_GDIPlus_BitmapDispose($NormalImage_Small)
_GDIPlus_ImageDispose($NormalImage_Exit)
_GDIPlus_ImageDispose($OverImage_Exit)
_GDIPlus_ImageDispose($PressedImage_Exit)
#EndRegion Dispose of Unused Handles

#Region Create Image GUI
$ImageGUI = GUICreate("Launcher-Playlet", $Width, $Height, $PosX, $PosY, $WS_POPUP, $WS_EX_LAYERED, $DS_MODALFRAME)

;Position Checking Labels
$LabelTop = 9
For $i = 1 To 11
    Switch $i
        Case 11
            $PositionArray[$i][0] = GUICtrlCreateLabel("", 118, $LabelTop, 38, 36) ;Exit Button
        Case Else
            $PositionArray[$i][0] = GUICtrlCreateLabel("", 12, $LabelTop, 144, 36) ;Other Position Labels
    EndSwitch

    $LabelTop += 41
Next

;Set State Variables
For $i = 1 To 11
    $PositionArray[$i][1] = 0 ;Normal = 0; Over = 1; Pressed = 2; Pressed, but not over on mouseup = 3
Next
SetBitmap($ImageGUI, $MainSkin, 255)
#EndRegion Create Image GUI

#Region Create Text GUI
$ControlGUI = GUICreate("ControlGUI", $Width, $Height, $PosX, $PosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED, $WS_EX_ACCEPTFILES), $ImageGUI)
GUISetFont(11, 400, -1, "Comic Sans MS")
GUISetBkColor(0x123456, $ControlGUI)

;Button Text Labels
$TextTop = 9
For $i = 1 To 12
    Switch $i
        Case 11
            $TextArray[$i] = GUICtrlCreateLabel("", 19, $TextTop + 5, 91, 13, BitOR($SS_CENTER, $SS_CENTERIMAGE)) ;Status Label
            GUICtrlSetFont(-1, 8)
        Case 12
            $TextArray[$i] = GUICtrlCreateLabel("", 19, $TextTop - 24, 91, 13, BitOR($SS_CENTER, $SS_CENTERIMAGE)) ;Usage Label
        Case Else
            $TextArray[$i] = GUICtrlCreateLabel("", 21, $TextTop + 6, 128, 25, $SS_CENTERIMAGE) ; + 0x08
            GUICtrlSetState(-1, $GUI_DROPACCEPTED)
            GUICtrlSetState(-1, $GUI_ONTOP)

            $Icon[$i] = GUICtrlCreatePic("", 125, $TextTop + $IconPosition, $IconSize, $IconSize)
            GUICtrlSetState(-1, $GUI_DISABLE)

            $Input[$i] = GUICtrlCreateInput("", 23, $TextTop + 9, 123, 19)
            GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
            GUICtrlSetFont(-1, 8.5)
            GUICtrlSetLimit(-1, 17, 0)
            GUICtrlSetState(-1, $GUI_HIDE)
    EndSwitch

    GUICtrlSetBkColor($TextArray[$i], $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor($TextArray[$i], 0xFFFFFF)
    $TextTop += 41
Next
_WinAPI_SetLayeredWindowAttributes($ControlGUI, 0x123456, 255)
#EndRegion Create Text GUI

GUISetState(@SW_SHOW, $ImageGUI)
GUISetState(@SW_SHOW, $ControlGUI)
GUIRegisterMsg($WM_MOVE, "WM_MOVE")

;Create Ini File, Load Settings
LoadSettings()

While 1
    If _IsPressed("11") And _IsPressed("12") And _IsPressed("50") Then PauseMode() ;CTRL + ALT + P --> Toggle
    If _IsPressed("11") And _IsPressed("12") And _IsPressed("43") Then ConfigMode() ;CTRL + ALT + C to activate; ESCAPE to deactivate (if it won't deactivate, click on gui and tehn press ESCAPE)

    $MousePos = MouseGetPos()

    If MouseActivateGUI($MousePos[0], $MousePos[1], False) Then
        Sleep(250) ;wait to see if mouse is just passing through while still keeping a reasonable response speed
        $MousePos = MouseGetPos()
        If MouseActivateGUI($MousePos[0], $MousePos[1], False) Then
            If $GUIState = "Shown" Then
                Do
                    $MousePos = MouseGetPos()
                    $CursorInfo = GUIGetCursorInfo($ImageGUI)

                    If $CursorInfo[2] = 1 Then
                        _SendMessage($ImageGUI, $WM_SYSCOMMAND, 0xF012, 0) ;SC_DRAGMOVE
                        ExitLoop
                    EndIf

                    #Region Button Checking Part
                    For $i = 1 To 11 ;cycle through all buttons
                        $MousePos = MouseGetPos()

                        If Not MouseActivateGUI($MousePos[0], $MousePos[1]) Then ExitLoop ;Don't check the rest of the buttons if the mouse isn't over the main GUI

                        Switch $CursorInfo[4]
                            Case $PositionArray[$i][0] ;If mouse is over the control
                                While $CursorInfo[4] = $PositionArray[$i][0] ;Loop while mouse is over the control
                                    $CursorInfo = GUIGetCursorInfo($ImageGUI)

                                    Switch $CursorInfo[2]
                                        Case 0 ;mouse is over button but not pressing it
                                            If getButtonState($i) <> 1 Then ;if button isn't already being hovered over
                                                setButtonState($i, 1)

                                                SetBitmap($ImageGUI, $Over[$i], 255)
                                                If $i < 11 Then ;if button isn't the exit button
                                                    GUICtrlSetFont($TextArray[$i], 11.5)
                                                    GUICtrlSetColor($TextArray[$i], 0x00ADFF)
                                                EndIf
                                            EndIf
                                        Case 1 ;mouse is over button and is pressing it
                                            If getButtonState($i) <> 2 Then ;if button isn't already being pressed
                                                setButtonState($i, 2)

                                                SetBitmap($ImageGUI, $Pressed[$i], 255)
                                                If $i < 11 Then ;if button isn't the exit button
                                                    GUICtrlSetFont($TextArray[$i], 12)
                                                    GUICtrlSetColor($TextArray[$i], 0xFA5000)
                                                EndIf
                                            EndIf

                                            While $CursorInfo[2] = 1 ;While mouse is being held down
                                                $CursorInfo = GUIGetCursorInfo($ImageGUI)

                                                If $CursorInfo[4] = $PositionArray[$i][0] Then ;if mouse is down and is over the button
                                                    If getButtonState($i) <> 2 Then ;if button isn't already being pressed
                                                        setButtonState($i, 2)

                                                        SetBitmap($ImageGUI, $Pressed[$i], 255)
                                                        If $i < 11 Then ;if button isn't the exit button
                                                            GUICtrlSetFont($TextArray[$i], 12)
                                                            GUICtrlSetColor($TextArray[$i], 0xFA5000)
                                                        EndIf
                                                    EndIf
                                                Else ;if mouse is down and is NOT over the button
                                                    If getButtonState($i) <> 3 Then
                                                        setButtonState($i, 3)

                                                        SetBitmap($ImageGUI, $Over[$i], 255)
                                                        If $i < 11 Then ;if button isn't the exit button
                                                            GUICtrlSetFont($TextArray[$i], 11.5)
                                                            GUICtrlSetColor($TextArray[$i], 0x00ADFF)
                                                        EndIf
                                                    EndIf
                                                EndIf

                                                Sleep(10)
                                            WEnd

                                            If $CursorInfo[4] = $PositionArray[$i][0] Then RunIt($i) ;still on the control after mouse is released
                                    EndSwitch

                                    Sleep(10)
                                WEnd

                                If $i < 11 Then
                                    GUICtrlSetFont($TextArray[$i], 11)
                                    GUICtrlSetColor($TextArray[$i], 0xFFFFFF)
                                EndIf

                                setButtonState($i, 0) ;set button state to normal
                                SetBitmap($ImageGUI, $MainSkin, 255)
                            Case Else
                                GetNetStatus() ;Update status fields only when not over the control - reduces usage
                        EndSwitch
                    Next
                    #EndRegion Button Checking Part

                    Sleep(10)
                Until Not MouseActivateGUI($MousePos[0], $MousePos[1], True)
            ElseIf $GUIState = "Hidden" Then
                ShowGUI()
            EndIf
        EndIf
    Else
        If $GUIState = "Shown" Then HideGUI()
    EndIf

    Sleep(20)
WEnd


Func _ResizeBitmap($sFile, $NewWidth, $NewHeight)
    Local $OldImage, $GC, $NewBmp, $NewGC

    ;Load Image
    $OldImage = _GDIPlus_ImageLoadFromFile($sFile)

    ;Create New Image
    $GC = _GDIPlus_ImageGetGraphicsContext($OldImage)
    $NewBmp = _GDIPlus_BitmapCreateFromGraphics($NewWidth, $NewHeight, $GC)
    $NewGC = _GDIPlus_ImageGetGraphicsContext($NewBmp)

    ;Draw Bitmap
    _GDIPlus_GraphicsDrawImageRect($NewGC, $OldImage, 0, 0, $NewWidth, $NewHeight)

    ;Cleanup Resources
    _GDIPlus_GraphicsDispose($GC)
    _GDIPlus_GraphicsDispose($NewGC)
    _GDIPlus_ImageDispose($OldImage)

    Return $NewBmp
EndFunc ;==>_ResizeBitmap

Func CleanUpOnExit()
    _GDIPlus_BitmapDispose($MainSkin)
    For $i = 1 To 11
        _GDIPlus_BitmapDispose($Over[$i])
        _GDIPlus_BitmapDispose($Pressed[$i])
    Next
    _GDIPlus_BitmapDispose($ConfigSkin)
    _GDIPlus_Shutdown()
EndFunc ;==>CleanUpOnExit

Func ConfigMode()
    Local $ReadLabels[11], $DraggedFile = "", $BlankString = "Drop Here " & Chr(17) & Chr(17) & Chr(17)
    Local $Check, $Msg, $DraggedFile, $ReadInput

    Sleep(100)
    TraySetIcon(@TempDir & "\PL-essential\state_icons.icl", 2)
    $Check = WinGetPos($ImageGUI)
    SetBitmap($ImageGUI, $ConfigSkin, 255)
    GUISetState(@SW_SHOW, $ControlGUI)
    GUISetState(@SW_SHOW, $ImageGUI)

    ShowGUI()

    For $i = 1 To 10
        $ReadLabels[$i] = GUICtrlRead($TextArray[$i])
        If $ReadLabels[$i] = "" Then GUICtrlSetData($TextArray[$i], $BlankString)
    Next

    While 1
        $Msg = GUIGetMsg($ControlGUI)

        Select
            Case _IsPressed("11") And _IsPressed("12") And _IsPressed("43") ;CTRL + ALT + C
                ExitLoop
            Case $Msg = $GUI_EVENT_DROPPED
                PoofSplash()

;~              $Choice = Ceiling((MouseGetPos(1) - getWinY($ImageGUI) + 9) / 41) ;math for a single drop label on the entire gui

                For $i = 1 To 10
                    If @GUI_DropId = $TextArray[$i] Then $Choice = $i
                Next

                GUICtrlSetImage($Icon[$Choice], "")
                $DraggedFile = @GUI_DragFile
                IniWrite($IniFile, "Run", $Choice, $DraggedFile)
                GUICtrlSetState($TextArray[$Choice], $GUI_HIDE)
                GUICtrlSetState($Input[$Choice], $GUI_SHOW)
                GUICtrlSetData($Input[$Choice], "Saved, enter text")
                If Not WinActive($ControlGUI) Then WinActivate($ControlGUI)
                GUICtrlSetState($Input[$Choice], $GUI_FOCUS)

                While 1
                    If _IsPressed("0D") And WinActive($ControlGUI) Then ExitLoop ;ENTER key to save button text
                    Sleep(10)
                WEnd

                $ReadInput = GUICtrlRead($Input[$Choice])
                GUICtrlSetState($Input[$Choice], $GUI_HIDE)
                GUICtrlSetState($TextArray[$Choice], $GUI_SHOW)
                If $ReadInput = "" Then
                    IniWrite($IniFile, "Run", $Choice, "")
                    $RunProgram[$Choice] = ""
                    MsgBox(0, "", "You can't leave the text field empty!" & @CRLF & "button reset!", 3)
                Else
                    IniWrite($IniFile, "Label Text", $Choice, $ReadInput)
                    GUICtrlSetData($TextArray[$Choice], $ReadInput) ;Reset Data To Text Label
                    $RunProgram[$Choice] = $DraggedFile ;Redeclare Variable
                    SetIcon($Choice)
                EndIf
        EndSelect

        Sleep(10)
    WEnd

    ;Reset Blank Fields
    For $i = 1 To 10
        $ReadLabels[$i] = GUICtrlRead($TextArray[$i])
        If $ReadLabels[$i] = $BlankString Then
            IniWrite($IniFile, "Label Text", $i, "")
            IniWrite($IniFile, "Run", $i, "")
            GUICtrlSetData($TextArray[$i], "")
        EndIf
    Next

    HideGUI()

    SetBitmap($ImageGUI, $MainSkin, 255)
    GUISetState(@SW_HIDE, $ControlGUI)
    GUISetState(@SW_HIDE, $ImageGUI)
    TraySetIcon(@TempDir & "\PL-essential\state_icons.icl", 1)
    Sleep(100)
EndFunc ;==>ConfigMode

Func ExitProgram()
    WinActivate($LastActiveWindow)
    DirRemove(@TempDir & "\PL-essential", 1)
    Exit
EndFunc ;==>ExitProgram

Func getButtonState($Index)
    Return $PositionArray[$Index][1]
EndFunc ;==>getButtonState

Func GetNetStatus()
    If $TimerInitiated = 0 Then
        $NetTimer = TimerInit()
        $TimerInitiated = 1
    Else
        If TimerDiff($NetTimer) > 2500 Or $FirstNetCheckup = 1 Then; updates status every 2,5 seconds
            Switch @IPAddress1
                Case "127.0.0.1"
                    $readoff = GUICtrlRead($TextArray[11])
                    If $readoff <> "Offline" Or $readoff = "" Then
                        GUICtrlSetData($TextArray[11], "Offline")
                        GUICtrlSetData($TextArray[12], "Usage: -")
                        $Offline = 1
                    EndIf
                Case Else
                    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)
                        EndIf
                        If DllStructGetData($iCntConn, 1) < 1 Then
                            SetError(1, 0, 0) ;Error: not opened connections
                        EndIf
                        GUICtrlSetData($TextArray[11], "Online (0')")
                        GUICtrlSetData($TextArray[12], "Usage: 0.00 mb")
                        $Offline = 0
                    EndIf
                    $aRet = DllCall("rasapi32.dll", "int", "RasGetConnectionStatistics", "hwnd", DllStructGetData($tRASCONN, "hRasConn"), "ptr", DllStructGetPtr($tRAS_STATS))
                    If $aRet[0] Then
                        SetError(3, $aRet[0], -1)
                    EndIf
                    $stat = DllStructGetData($tRAS_STATS, "dwBytesXmited")
                    $stat2 = DllStructGetData($tRAS_STATS, "dwBytesRcved")
                    $stat3 = DllStructGetData($tRAS_STATS, "dwConnectDuration")
                    $totalsummb = Round((($stat + $stat2) / 1048576), 2)
                    $time = Floor((($stat3 / 1000) / 60))
                    If $totalsummb <> $LastTotalSumMB And ($totalsummb - $LastTotalSumMB) >= 0.125 Then; updates label every 125 kb
                        GUICtrlSetData($TextArray[12], "Usage: " & $totalsummb & " mb")
                        $LastTotalSumMB = $totalsummb
                    EndIf
                    If $time <> $LastTime Then; updates label every minute
                        GUICtrlSetData($TextArray[11], "Online (" & $time & "')")
                        $LastTime = $time
                    EndIf
            EndSwitch
            $TimerInitiated = 0
            If Not $FirstNetCheckup = 0 Then $FirstNetCheckup = 0
        EndIf
    EndIf
EndFunc ;==>GetNetStatus

Func getWinY($hWnd)
    Local $WinPos = WinGetPos($hWnd)

    Return $WinPos[1]
EndFunc ;==>getWinY

Func HideGUI()
    Local $CurrentY = getWinY($ImageGUI)

    $GUIState = "Hidden"

    Switch $Side
        Case "Right"
            For $i = $PosX To $PosX + $Width Step 11
                WinMove($ImageGUI, "", $i, $CurrentY)
                WinMove($ControlGUI, "", $i, $CurrentY)
            Next
        Case "Left"
            For $i = 0 To -($Width) Step -11
                WinMove($ImageGUI, "", $i, $CurrentY)
                WinMove($ControlGUI, "", $i, $CurrentY)
            Next
    EndSwitch

    GUISetState(@SW_HIDE, $ControlGUI)
    GUISetState(@SW_HIDE, $ImageGUI)
    If $LastActiveWindow <> "" Then WinActivate($LastActiveWindow)
EndFunc ;==>HideGUI

Func LoadNetChecking()
    Local Const $MAX_PATH = 260
    Local Const $RAS_MaxDeviceType = 16
    Local Const $RAS_MaxEntryName = 256
    Local Const $RAS_MaxDeviceName = 128
    $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]")
    $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")
    $iCntByte = DllStructCreate("dword")
    $iCntConn = DllStructCreate("dword")
    DllStructSetData($iCntByte, 1, DllStructGetSize($tRASCONN))
    DllStructSetData($tRASCONN, "dwSize", DllStructGetSize($tRASCONN))
    DllStructSetData($tRAS_STATS, "dwSize", DllStructGetSize($tRAS_STATS))
EndFunc ;==>LoadNetChecking

Func LoadSettings()
    If FileExists($IniFile) Then
        For $i = 1 To 10
            $LabelText[$i] = IniRead($IniFile, "Label Text", $i, "")
            GUICtrlSetData($TextArray[$i], $LabelText[$i])
            $RunProgram[$i] = IniRead($IniFile, "Run", $i, "")
            SetIcon($i)
        Next
    Else
        Local $Question = MsgBox(4, "Playlet's Launcher: Settings", "Would you like to setup button text and programs now?")
        If $Question = 6 Then
            ConfigMode()
        Else
            For $i = 1 To 10
                IniWrite($IniFile, "Label Text", $i, "")
                IniWrite($IniFile, "Run", $i, "")
                $RunProgram[$i] = ""
            Next
        EndIf
    EndIf
EndFunc ;==>LoadSettings

Func PauseMode()
    TraySetIcon(@TempDir & "\PL-essential\state_icons.icl", 3)
    Sleep(100)
    Do
        Sleep(25)
    Until _IsPressed("11") And _IsPressed("12") And _IsPressed("50") ;CTRL + ALT + P
    TraySetIcon(@TempDir & "\PL-essential\state_icons.icl", 1)
    Sleep(100)
EndFunc ;==>PauseMode

Func PoofSplash()
    Local $MousePosition, $PoofPNG, $SplashGUI_On, $Top, $Poof

    $MousePosition = MouseGetPos()
    $PoofPNG = _GDIPlus_ImageLoadFromFile(@TempDir & "\PL-essential\Poof.png")

    $SplashGUI_On = GUICreate("", 128, 128, $MousePosition[0] - 60, $MousePosition[1] - 60, $WS_POPUP, $WS_EX_LAYERED, $DS_MODALFRAME)
    GUISetState(@SW_SHOW, $SplashGUI_On)
    WinSetOnTop($SplashGUI_On, "", 1)

    $Top = 0
    For $i = 1 To 5
        $Poof = _GDIPlus_BitmapCloneArea($PoofPNG, 0, $Top, 128, 128, $GDIP_PXF32ARGB)
        SetBitmap($SplashGUI_On, $Poof, 255)

        $Top += 128
        Sleep(50)
        _WinAPI_DeleteObject($Poof)
    Next

    GUIDelete($SplashGUI_On)
    _GDIPlus_ImageDispose($PoofPNG)
EndFunc ;==>PoofSplash

Func RunIt($WhichOne)
    $LastActiveWindow = ""

    Switch $RunProgram[$WhichOne] ;if run program is defined then...
        Case ""
            Switch $WhichOne
                Case 1 To 10
                    MsgBox(0, "", "Button " & $WhichOne, 3)
                Case 11 ;Exit Button
                    Beep(1000, 50)
                    Beep(2000, 50)
                    Beep(500, 50)
                    ExitProgram()
            EndSwitch
        Case Else
            Switch $WhichOne
                Case 1 To 10
                    ShellExecute($RunProgram[$WhichOne])
                Case 11 ;Exit Button
                    Beep(1000, 50)
                    Beep(2000, 50)
                    Beep(500, 50)
                    ExitProgram()
            EndSwitch
    EndSwitch

    Beep(1000, 50)
    Beep(2000, 50)
EndFunc ;==>RunIt

Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld
    Local Const $AC_SRC_ALPHA = 1
    $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 setButtonState($Index, $State)
    $PositionArray[$Index][1] = $State
EndFunc ;==>setButtonState

Func SetIcon($Number)
    $IniRead = IniRead($IniFile, "Run", $Number, "")
    If $IniRead <> "" And FileExists($IniRead) Then
        If Not StringInStr(FileGetAttrib($IniRead), "D") Then
            $SplitName = StringSplit($IniRead, ".", 1)
            Switch $SplitName[$SplitName[0]]
                Case "exe"
                    $hIcon = _Icons_Icon_Extract($IniRead, 0, $IconSize, $IconSize)
                Case Else
                    $IconPath = RetrieveIconPath($IniRead)
                    $hIcon = _Icons_Icon_Extract($IconPath[0], $IconPath[1], $IconSize, $IconSize)
            EndSwitch
        Else
            $hIcon = _Icons_Icon_Extract(@WindowsDir & "\explorer.exe", 13, $IconSize, $IconSize)
        EndIf

        $hBitmap = _Icons_Bitmap_CreateFromIcon($hIcon)
        _SetHImage($Icon[$Number], $hBitmap)
        _WinAPI_DeleteObject($hBitmap)
        _WinAPI_DestroyIcon($hIcon)
    EndIf
EndFunc ;==>SetIcon

Func ShowGUI()
    Local $CurrentY = getWinY($ImageGUI)

    $LastActiveWindow = WinGetTitle("[active]")
    GUISetState(@SW_SHOW, $ControlGUI)
    GUISetState(@SW_SHOW, $ImageGUI)

    Switch $Side
        Case "Right"
            For $i = $PosX + $Width To $PosX Step -11
                WinMove($ImageGUI, "", $i, $CurrentY)
                WinMove($ControlGUI, "", $i, $CurrentY)
            Next
        Case "Left"
            For $i = -($Width) To 0 Step 11
                WinMove($ImageGUI, "", $i, $CurrentY)
                WinMove($ControlGUI, "", $i, $CurrentY)
            Next
    EndSwitch

    $GUIState = "Shown"
EndFunc ;==>ShowGUI

Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
    If $hWnd = $ImageGUI And $GUIState = "Shown" Then
        Local $NewX = _WinAPI_LoWord($lParam)
        Local $NewY = _WinAPI_HiWord($lParam)

        If $NewX < @DesktopWidth / 2 Then
            $Side = "Left"
            $NewX = 0
        Else
            $Side = "Right"
            $NewX = @DesktopWidth - $Width
        EndIf

        WinMove($ImageGUI, "", $NewX, $NewY)
        WinMove($ControlGUI, "", $NewX, $NewY)
    EndIf
EndFunc ;==>WM_MOVE

Func _ImageDraw($State = "normal", $Case = "") ;Draw A Picture On A PNG
    Local $hGraphic1, $hGraphic2, $hBitmap
    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 onto 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
        Case "config"
            For $i = 1 To 10
                $Image[$i] = $OverImage
            Next
    EndSwitch

    For $i = 1 To 10
        _GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[$i], 0, ($i - 1) * 41, 167, 57)
    Next

    _GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[11], 4, 410, 119, 57)
    _GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[12], 110, 412, 53, 52)

    ;Cleanup Resources
    _GDIPlus_GraphicsDispose($hGraphic2)
    _GDIPlus_GraphicsDispose($hGraphic1)

    ;Return the new bitmap
    Return $hBitmap
EndFunc ;==>_ImageDraw

Func MouseActivateGUI($X, $Y, $IgnoreMouse = True) ;returns true if mouse is near enough to the edge of the screen to activate the main GUI
    If Not $IgnoreMouse Then
        If _IsPressed("01") Then Return SetExtended(1, False)
    EndIf
    If $Y < 40 Then Return SetExtended(2, False)
    If $Y > @DesktopHeight - 40 Then Return SetExtended(3, False)

    Switch $Side
        Case "Right"
            Switch $GUIState
                Case "Shown"
                    $GUIPos = WinGetPos($ImageGUI)

                    If $X > @DesktopWidth - $Sensitivity Then Return SetExtended(4, True)
                    If ($X > $GUIPos[0]) And ($Y > $GUIPos[1]) And ($Y < ($GUIPos[1] + $GUIPos[3])) Then Return SetExtended(5, True)
                Case "Hidden"
                    If $X > @DesktopWidth - $Sensitivity Then Return SetExtended(6, True)
            EndSwitch
        Case "Left"
            Switch $GUIState
                Case "Shown"
                    $GUIPos = WinGetPos($ImageGUI)

                    If $X < $Sensitivity Then Return SetExtended(7, True)
                    If ($X < $GUIPos[2]) And ($Y > $GUIPos[1]) And ($Y < ($GUIPos[1] + $GUIPos[3])) Then Return SetExtended(8, True)
                Case "Hidden"
                    If $X < $Sensitivity Then Return SetExtended(9, True)
            EndSwitch
    EndSwitch

    Return SetExtended(10, False)
EndFunc ;==>MouseActivateGUI
#Region Functions from DanTay9's launcher (Toolbar Launcher = "http://www.autoitscript.com/forum/index.php?showtopic=102956")

Func _GetRegDefIcon($sPath)
    Local Const $DF_NAME = @SystemDir & "\shell32.dll", $DF_INDEX = 0
    Local $FileName, $Count, $Name, $Ext, $Curver, $DefaultIcon, $Ret[2] = [$DF_NAME, $DF_INDEX]

    $FileName = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
    $Count = StringInStr($FileName, ".", 0, -1)

    If $Count > 0 Then $Count = StringLen($FileName) - $Count + 1

    $Name = StringStripWS(StringTrimRight($FileName, $Count), 3)
    $Ext = StringStripWS(StringRight($FileName, $Count - 1), 8)

    If StringLen($Ext) = 0 Then Return $Ret

    $Curver = StringStripWS(RegRead('HKCR\' & RegRead('HKCR\' & '.' & $Ext, '') & '\CurVer', ''), 3)

    If (@error) Or (StringLen($Curver) = 0) Then
        $DefaultIcon = _WinAPI_ExpandEnvironmentStrings(StringReplace(RegRead('HKCR\' & RegRead('HKCR\' & '.' & $Ext, '') & '\DefaultIcon', ''), '''', ''))
    Else
        $DefaultIcon = _WinAPI_ExpandEnvironmentStrings(StringReplace(RegRead('HKCR\' & $Curver & '\DefaultIcon', ''), '''', ''))
    EndIf

    $Count = StringInStr($DefaultIcon, ',', 0, -1)
    If $Count > 0 Then
        $Count = StringLen($DefaultIcon) - $Count
        $Ret[0] = StringStripWS(StringTrimRight($DefaultIcon, $Count + 1), 3)
        If $Count > 0 Then $Ret[1] = StringStripWS(StringRight($DefaultIcon, $Count), 8)
    Else
        $Ret[0] = StringStripWS(StringTrimRight($DefaultIcon, $Count), 3)
    EndIf

    If StringLeft($Ret[0], 1) = '%' Then
        $Count = DllCall('shell32.dll', 'int', 'ExtractIcon', 'int', 0, 'str', $sPath, 'int', -1)
        If $Count[0] = 0 Then
            $Ret[0] = $DF_NAME
            If StringLower($Ext) = 'exe' Then
                $Ret[1] = 2
            Else
                $Ret[1] = 0
            EndIf
        Else
            $Ret[0] = StringStripWS($sPath, 3)
            $Ret[1] = 0
        EndIf
    Else
        If (StringLen($Ret[0]) > 0) And (StringInStr($Ret[0], '\', 0) = 0) Then $Ret[0] = @SystemDir & '\' & $Ret[0]
    EndIf

    If Not FileExists($Ret[0]) Then
        $Ret[0] = $DF_NAME
        $Ret[1] = $DF_INDEX
    EndIf

    Return $Ret
EndFunc ;==>_GetRegDefIcon
Func RetrieveIconPath($sPath)
    Local $Reg, $DefaultBrowser, $Short

    $Reg = StringRegExp($sPath, "(?<Protocol>\w+):\/\/(?<Domain>[\w@][\w.:@]+)\/?[\w\.?=%&=\-@/$,]*", 3)
    If (IsArray($Reg) And UBound($Reg) = 2 And ($Reg[0] = "http" Or $Reg[0] = "https")) Or StringLeft($sPath, 4) = "www." Then
        $DefaultBrowser = RegRead("HKEY_CLASSES_ROOT\http\shell\open\command", "")
        $DefaultBrowser = StringTrimLeft($DefaultBrowser, 1)
        $DefaultBrowser = StringMid($DefaultBrowser, 1, StringInStr($DefaultBrowser, '"') - 1)
        $Reg = _GetRegDefIcon($DefaultBrowser)

        Return SetError(0, 1, $Reg)
    ElseIf StringRight($sPath, 4) = ".lnk" Then
        $Short = FileGetShortcut($sPath)
        $Reg = _GetRegDefIcon($Short[0])

        Return SetError(0, 2, $Reg)
    Else
        $Reg = _GetRegDefIcon($sPath)

        Return SetError(0, 3, $Reg)
    EndIf

    Return SetError(-1, -1, -1)
EndFunc ;==>RetrieveIconPath
#EndRegion Functions from DanTay9's launcher (Toolbar Launcher = "http://www.autoitscript.com/forum/index.php?showtopic=102956")

#Region Functions from Yashied's UDF (Icons.au3 - "http://www.autoitscript.com/forum/index.php?showtopic=92675")
Func _Icons_Bitmap_CreateFromIcon($hIcon)
    Local $tICONINFO = DllStructCreate($tagICONINFO)
    Local $Ret, $hBitmap
    $Ret = DllCall('user32.dll', 'int', 'GetIconInfo', 'ptr', $hIcon, 'ptr', DllStructGetPtr($tICONINFO))
    If (@error) Or ($Ret[0] = 0) Then
        Return 0
    EndIf
    $hBitmap = _Icons_Bitmap_Duplicate(DllStructGetData($tICONINFO, 5), 1)
    If Not _Icons_Bitmap_IsAlpha($hBitmap) Then
        _GDIPlus_Startup()
        _WinAPI_DeleteObject($hBitmap)
        $Ret = DllCall($ghGDIPDll, 'int', 'GdipCreateBitmapFromHICON', 'ptr', $hIcon, 'ptr*', 0)
        If (Not @error) And ($Ret[0] = 0) Then
            $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Ret[2])
            _GDIPlus_ImageDispose($Ret[2])
        Else
            $hBitmap = 0
        EndIf
        _GDIPlus_Shutdown()
    EndIf
    Return $hBitmap
EndFunc ;==>_Icons_Bitmap_CreateFromIcon

Func _Icons_Bitmap_Duplicate($hBitmap, $fDelete = 0)
    If $fDelete Then
        $fDelete = $LR_COPYDELETEORG
    EndIf
    Local $Ret = DllCall('user32.dll', 'hwnd', 'CopyImage', 'ptr', $hBitmap, 'int', 0, 'int', 0, 'int', 0, 'int', BitOR($LR_CREATEDIBSECTION, $fDelete))
    If (@error) Or ($Ret[0] = 0) Then
        Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
EndFunc ;==>_Icons_Bitmap_Duplicate

Func _Icons_Bitmap_IsAlpha($hBitmap)
    Local $Ret, $tBits
    $Ret = DllCall('gdi32.dll', 'int', 'GetBitmapBits', 'ptr', $hBitmap, 'long', 0, 'ptr', 0)
    If (@error) Or ($Ret[0] = 0) Then
        Return SetError(1, 0, 0)
    EndIf
    $Lenght = $Ret[0] / 4
    $tBits = DllStructCreate('dword[' & $Lenght & ']')
    $Ret = DllCall('gdi32.dll', 'int', 'GetBitmapBits', 'ptr', $hBitmap, 'long', $Ret[0], 'ptr', DllStructGetPtr($tBits))
    If (@error) Or ($Ret[0] = 0) Then
        Return SetError(1, 0, 0)
    EndIf
    For $i = 1 To $Lenght
        If BitAND(DllStructGetData($tBits, 1, $i), 0xFF000000) Then
            Return 1
        EndIf
    Next
    Return 0
EndFunc ;==>_Icons_Bitmap_IsAlpha
Func _Icons_Control_SetImage($hWnd, $hImage, $iType, $hOverlap)
    Local $Static, $Style, $Update, $tRect, $hPrev
    Switch $iType
        Case $IMAGE_BITMAP
            $Static = $__SS_BITMAP
        Case $IMAGE_ICON
            $Static = $__SS_ICON
        Case Else
            Return 0
    EndSwitch
    $Style = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
    If @error Then
        Return 0
    EndIf
    _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitOR($Style, $Static))
    If @error Then
        Return 0
    EndIf
    $tRect = _Icons_Control_GetRect($hWnd)
    $hPrev = _SendMessage($hWnd, $__STM_SETIMAGE, $iType, $hImage)
    If @error Then
        Return 0
    EndIf
    If $hPrev Then
        If $iType = $IMAGE_BITMAP Then
            _WinAPI_DeleteObject($hPrev)
        Else
            _WinAPI_DestroyIcon($hPrev)
        EndIf
    EndIf
    If (Not $hImage) And (IsDllStruct($tRect)) Then
        _WinAPI_MoveWindow($hWnd, DllStructGetData($tRect, 1), DllStructGetData($tRect, 2), DllStructGetData($tRect, 3) - DllStructGetData($tRect, 1), DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2), 0)
    EndIf
    If $hOverlap Then
        If Not IsHWnd($hOverlap) Then
            $hOverlap = 0
        EndIf
        _Icons_Control_Update($hWnd, $hOverlap)
    Else
        _Icons_Control_Invalidate($hWnd)
    EndIf
    Return 1
EndFunc ;==>_Icons_Control_SetImage

Func _Icons_Control_Enum($hWnd, $iDirection)
    Local $iWnd, $Count = 0, $aWnd[50] = [$hWnd]
    If $iDirection Then
        $iDirection = $GW_HWNDNEXT
    Else
        $iDirection = $GW_HWNDPREV
    EndIf
    While 1
        $iWnd = _WinAPI_GetWindow($aWnd[$Count], $iDirection)
        If Not $iWnd Then
            ExitLoop
        EndIf
        $Count += 1
        If $Count = UBound($aWnd) Then
            ReDim $aWnd[$Count + 50]
        EndIf
        $aWnd[$Count] = $iWnd
    WEnd
    ReDim $aWnd[$Count + 1]
    Return $aWnd
EndFunc ;==>_Icons_Control_Enum

Func _Icons_Control_Update($hWnd, $hOverlap)
    Local $tBack, $tFront = _Icons_Control_GetRect($hWnd)
    If $tFront = 0 Then
        Return
    EndIf
    Local $aNext = _Icons_Control_Enum($hWnd, 1)
    Local $aPrev = _Icons_Control_Enum($hWnd, 0)
    If UBound($aPrev) = 1 Then
        _WinAPI_InvalidateRect(_WinAPI_GetParent($hWnd), $tFront)
        Return
    EndIf
    Local $aWnd[UBound($aNext) + UBound($aPrev - 1)]
    Local $tIntersect = DllStructCreate($tagRECT), $pIntersect = DllStructGetPtr($tIntersect)
    Local $iWnd, $Ret, $XOffset, $YOffset, $Count = 0, $Update = 0
    For $i = UBound($aPrev) - 1 To 1 Step -1
        $aWnd[$Count] = $aPrev[$i]
        $Count += 1
    Next
    For $i = 0 To UBound($aNext) - 1
        $aWnd[$Count] = $aNext[$i]
        $Count += 1
    Next
    For $i = 0 To $Count - 1
        If $aWnd[$i] = $hWnd Then
            _WinAPI_InvalidateRect($hWnd)
        Else
            If (Not $hOverlap) Or ($aWnd[$i] = $hOverlap) Then
                $tBack = _Icons_Control_GetRect($aWnd[$i])
                $Ret = DllCall('user32.dll', 'int', 'IntersectRect', 'ptr', $pIntersect, 'ptr', DllStructGetPtr($tFront), 'ptr', DllStructGetPtr($tBack))
                If (Not @error) And ($Ret[0]) Then
                    $Ret = DllCall('user32.dll', 'int', 'IsRectEmpty', 'ptr', $pIntersect)
                    If (Not @error) And (Not $Ret[0]) Then
                        $XOffset = DllStructGetData($tBack, 1)
                        $YOffset = DllStructGetData($tBack, 2)
                        $Ret = DllCall('user32.dll', 'int', 'OffsetRect', 'ptr', $pIntersect, 'int', -$XOffset, 'int', -$YOffset)
                        If (Not @error) And ($Ret[0]) Then
                            _WinAPI_InvalidateRect($aWnd[$i], $tIntersect)
                            $Update += 1
                        EndIf
                    EndIf
                EndIf
            EndIf
        EndIf
    Next
    If Not $Update Then
        _WinAPI_InvalidateRect(_WinAPI_GetParent($hWnd), $tFront)
    EndIf
EndFunc ;==>_Icons_Control_Update

Func _Icons_Control_Invalidate($hWnd)
    Local $tRect = _Icons_Control_GetRect($hWnd)
    If IsDllStruct($tRect) Then
        _WinAPI_InvalidateRect(_WinAPI_GetParent($hWnd), $tRect)
    EndIf
EndFunc ;==>_Icons_Control_Invalidate

Func _Icons_Control_GetRect($hWnd)
    Local $Pos = ControlGetPos($hWnd, '', '')
    If (@error) Or ($Pos[2] = 0) Or ($Pos[3] = 0) Then
        Return 0
    EndIf
    Local $tRect = DllStructCreate($tagRECT)
    DllStructSetData($tRect, 1, $Pos[0])
    DllStructSetData($tRect, 2, $Pos[1])
    DllStructSetData($tRect, 3, $Pos[0] + $Pos[2])
    DllStructSetData($tRect, 4, $Pos[1] + $Pos[3])
    Return $tRect
EndFunc ;==>_Icons_Control_GetRect

Func _Icons_Control_CheckHandle($hWnd)
    If Not IsHWnd($hWnd) Then
        $hWnd = GUICtrlGetHandle($hWnd)
        If $hWnd = 0 Then
            Return 0
        EndIf
    EndIf
    Return $hWnd
EndFunc ;==>_Icons_Control_CheckHandle

Func _Icons_Icon_Extract($sIcon, $iIndex, $iWidth, $iHeight)
    Local $Ret = DllCall('shell32.dll', 'int', 'SHExtractIconsW', 'wstr', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr*', 0, 'int', 1, 'int', 0)
    If (@error) Or ($Ret[0] = 0) Then
        Return SetError(1, 0, 0)
    EndIf
    Return $Ret[5]
EndFunc ;==>_Icons_Icon_Extract

Func _SetHImage($hWnd, $hBitmap, $hOverlap = 0)
    $hWnd = _Icons_Control_CheckHandle($hWnd)
    If $hWnd = 0 Then
        Return SetError(1, 0, 0)
    EndIf
    Local $Result, $hImage
    If Not ($hOverlap < 0) Then
        $hOverlap = _Icons_Control_CheckHandle($hOverlap)
    EndIf
    $hBitmap = _Icons_Bitmap_Duplicate($hBitmap)
    $Result = _Icons_Control_SetImage($hWnd, $hBitmap, $IMAGE_BITMAP, $hOverlap)
    If $Result Then
        $hImage = _SendMessage($hWnd, $__STM_GETIMAGE, $IMAGE_BITMAP, 0)
        If (@error) Or ($hBitmap = $hImage) Then
            $hBitmap = 0
        EndIf
    EndIf
    If $hBitmap Then
        _WinAPI_DeleteObject($hBitmap)
    EndIf
    Return SetError(1 - $Result, 0, $Result)
EndFunc ;==>_SetHImage
#EndRegion Functions from Yashied's UDF (Icons.au3 - "http://www.autoitscript.com/forum/index.php?showtopic=92675")
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...