Jump to content

---


playlet
 Share

Recommended Posts

@automatedfaults

The point of this program is for it to look good and to be useful, both of which are true. If you are looking for lower memory usage, you probably shouldn't be looking at autoit. If you want less memory, you should look at lower level languages.

Link to comment
Share on other sites

  • Replies 338
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

To Dantay 9

I am using object dock+ at the moment and it has also graphic effects and tabbs with a lot of program shortcuts on it etc and it uses 6mb. Thats why I continue using it although I try others from time to time to compare - I always find they use a lot more memory but 15mb is the most I have had.

ps what lower level language do you recommend...erm autohotkey?!! :mellow:

To Playlet

I'ts probably a great program I just cant get to try it! it also crashes if i dont call up taskmanager. I am pretty sure this is just my system though - for one thing i am using Talisman desktop!

the bracket difference ( or [ I probably just typed it wrong. but I havent messed with the code at all.

Anyway no worries, great work anyway!

Edited by automatedfaults
Link to comment
Share on other sites

To Dantay 9

I am using object dock+ at the moment and it has also graphic effects and tabbs with a lot of program shortcuts on it etc and it uses 6mb. Thats why I continue using it although I try others from time to time to compare - I always find they use a lot more memory but 15mb is the most I have had.

ps what lower level language do you recommend...erm autohotkey?!! :mellow:

If you find the memory usage extravagant ( don't), you have the power to fix it....or perhaps Playlet will if you ask. The below function can be called right before the while statement and will reduce the memory usage to 1mb....Let's see your object dock beat that....You may have to call it again after a certain period of time if you want to maintain that level.

Can Autohotkey make GUIs? I thought the code they stole from Autoit was pre-gui.

_ReduceMemory()
Func _ReduceMemory($ProcID = 0)
; Original version : w_Outer 
; modified by Rajesh V R to include process ID 
    If $ProcID = 0 or ProcessExists($ProcID) = 0 Then ; No process id specified or process doesnt exist - use current process instead.
        Local $ai_GetCurrentProcessId = DllCall('kernel32.dll', 'int', 'GetCurrentProcessId')
        $ProcID = $ai_GetCurrentProcessId[0]
    EndIf
    
    Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $ai_GetCurrentProcessId[0])
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Return $ai_Return[0]

EndFunc
Link to comment
Share on other sites

@automatedfaults

You can't go wrong with C++. Autoit isn't typically associated with really small programs. I forgot about that function picea showed. That will do the job. But if the memory is able to be cleared with that function, it wasn't hurting anything in the first place (unless you have very little RAM).

P.S. I too use ObjectDock and it is wonderful. I am so glad to get rid of the windows taskbar. The only thing I miss is the clock. Do you have a replacement icon for the clock?

Edit: If you truly want to reduce the memory for good, you will have to implement a timer to call the function like once every two minutes. Otherwise, when you mouse over the buttons, the memory usage just goes right back up.

Edited by dantay9
Link to comment
Share on other sites

This isn't a big deal, but when I have my computer in 16-bit color (to save on cpu), the toolbar doesn't work correctly. I would suggest replacing lines 86 and 111 with these two lines:

GUISetBkColor(0x003842, $ControlGUI)
_WinAPI_SetLayeredWindowAttributes($ControlGUI, 0x003842, 255)

This color doesn't seem very common, but still allows the toolbar to work on 16-bit computers. This is just a suggestion that won't affect most people at all, but will help those of us that have old computers (like mine).

Also, do you plan to put this on another download site and distribute this? That would be a good idea. An installer and a tray for easy access to the help file would pretty much complete this program.

Edit: Oops, already proposed these ideas.

Edited by dantay9
Link to comment
Share on other sites

Hi Playlet.

Surprise...I have other ideas.....

1) If the launcher is dragged to the secondary monitor it gets confused. Either, the script should go back to it's default location if dragged and dropped off the primary monitor (that is my suggestion)...or, this may be difficult you could make it work on the secondary monitor. I know there are examples on the forum for identifying if there is one or two monitors. I'm guessing there must be a way to get the dimensions of the secondary monitor and the location in relation to the primary. Seems like more work than it is worth.

2) Wondering if you could give the user the option of what is displayed on the net status label. If someone preferred CPU or memory usage perhaps they could change if they wanted.

3) What about sorting the submenu. If I drag 3 folders to a button: Example: 2011, 2010, 2012. In my mind it should automatically sort numerically or alphabetically.

Picea.

Edited by picea892
Link to comment
Share on other sites

For your cpu usage problem, here are some links. I have had no problems with anyr of them.

http://www.autoitscript.com/forum/index.php?showtopic=98592 great way to measure cpu usage of autoit script

http://www.autoitscript.com/forum/index....owtopic=53973&st=0&p=409276&#entry409276 _ProcessListProperties function

http://www.autoitscript.com/forum/index.php?showtopic=55877 good example of last link

Edited by dantay9
Link to comment
Share on other sites

Beege (first link) has a great script. I did use AdlibRegister, but it seems to work without slowing down the gui. I even changed the delay to 1000 milliseconds instead of 2500. This is just for CPU usage, nothing else. Here is the simple test I implemented:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=devilish.ico
#AutoIt3Wrapper_Outfile=Playlet's Launcher.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Description=Launcher made by Playlet
#AutoIt3Wrapper_Res_Fileversion=4.0.2.8
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

If _Singleton(@ScriptName, 1) = 0 Then
    MsgBox(16, "Playlet's Launcher", "Dear user" & @CRLF & @CRLF & "Due to practical reasons, you can only start this application once!", 4)
    Exit
EndIf

TrayTip("Playlet's Launcher", "Please wait, setting up PL-Launcher.", 0, 1)

If Not FileExists(@TempDir & "\PL-essential\") Then DirCreate(@TempDir & "\PL-essential")
FileInstall("devilish.ico", @TempDir & "\PL-essential\devilish.ico", 1)
TraySetIcon(@TempDir & "\PL-essential\devilish.ico")
FileInstall("config_pause_icons.icl", @TempDir & "\PL-essential\config_pause_icons.icl", 1)
FileInstall("PL-Skin.png", @TempDir & "\PL-essential\PL-Skin.png", 1)
FileInstall("Poof.png", @TempDir & "\PL-essential\Poof.png", 1)

#include-once
#include <Array.au3>
#include <WinAPI.au3>
#include <PL_Includes.au3>

Opt("TrayMenuMode", 3)
OnAutoItExitRegister("ExitProgram")

Global $tray_mode = TrayCreateItem("Pause Mode")
Global $tray_check = TrayCreateItem("Check/sort button items")
Global $tray_instr = TrayCreateItem("Instructions")
Global $tray_about = TrayCreateItem("About")
TrayCreateItem("")
Global $tray_exit = TrayCreateItem("Exit Program")

Global $ProcessCpu, $TotalCpu, $nProcessCpu, $StartUser, $StartIdle, $StartKernel, $ProcStartKern, $ProcStartUser, $bFirstRun = True

Global $ImageGUI, $ControlGUI, $JumplistMGUI, $JumplistTextGUI, $positionarray[12][2], $textarray[13], $icon[11], $input[11], $JumplistLabelArraytitle, $JumplistLabelArray[16][2]
Global $jump_icon, $MainSkin, $over[12], $pressed[12], $timer = TimerInit(), $tRASCONN, $iCntByte, $iCntConn, $tRAS_STATS, $offline = 2, $lasttotalsummb = 0
Global $lasttime = 0, $Width = 167, $Height = 468, $pl_pos[2], $Side_choice, $Up_sens = 0, $Down_sens = 0, $Left_sens = 0, $Right_sens = 0, $PL_Launcher_state = "Shown"
Global $DropFilesArray[1], $DesktopHeight = @DesktopHeight, $DesktopWidth = @DesktopWidth, $ini_file = @ScriptDir & "\Config.ini", $default_button, $MemTimer = TimerInit()
Global $SGSens = 5; ########### YOU MIGHT NEED TO MODIFY THIS --> SHOW GUI SENSITIVITY #############################################################################

Startup_Settings()

_GDIPlus_Startup()
Global $PL_Skin_image = _GDIPlus_ImageLoadFromFile(@TempDir & "\PL-essential\PL-Skin.png")
Global $Normal_Image = _GDIPlus_BitmapCloneArea($PL_Skin_image, 0, 0, $Width, 57, $GDIP_PXF32ARGB)
Global $Over_Image = _GDIPlus_BitmapCloneArea($PL_Skin_image, 0, 57, $Width, 57, $GDIP_PXF32ARGB)
Global $Pressed_Image = _GDIPlus_BitmapCloneArea($PL_Skin_image, 0, 112, $Width, 57, $GDIP_PXF32ARGB)
Global $Exit_Image_Normal = _GDIPlus_BitmapCloneArea($PL_Skin_image, $Width, 0, 61, 57, $GDIP_PXF32ARGB)
Global $Exit_Image_Over = _GDIPlus_BitmapCloneArea($PL_Skin_image, $Width, 57, 61, 57, $GDIP_PXF32ARGB)
Global $Exit_Image_Pressed = _GDIPlus_BitmapCloneArea($PL_Skin_image, $Width, 112, 61, 57, $GDIP_PXF32ARGB)
Global $Jumplist_BG = _GDIPlus_BitmapCloneArea($PL_Skin_image, 0, 171, 220, 299, $GDIP_PXF32ARGB)
$MainSkin = Image_Draw()
For $i = 1 To 11
    $over[$i] = Image_Draw("over", $i)
    $pressed[$i] = Image_Draw("pressed", $i)
Next
_GDIPlus_ImageDispose($PL_Skin_image)
_GDIPlus_ImageDispose($Normal_Image)
_GDIPlus_ImageDispose($Over_Image)
_GDIPlus_ImageDispose($Pressed_Image)
_GDIPlus_ImageDispose($Exit_Image_Normal)
_GDIPlus_ImageDispose($Exit_Image_Over)
_GDIPlus_ImageDispose($Exit_Image_Pressed)

; IMAGE GUI
$ImageGUI = GUICreate("Launcher-Playlet", $Width, $Height, $pl_pos[0], $pl_pos[1], $WS_POPUP, $WS_EX_LAYERED + $WS_EX_ACCEPTFILES, $DS_MODALFRAME)
$labelposition = 9
For $i = 1 To 11; Position checking labels
    Switch $i
        Case 11
            $positionarray[$i][0] = GUICtrlCreateLabel("", 119, $labelposition, 37, 36); Exit button
        Case Else
            $positionarray[$i][0] = GUICtrlCreateLabel("", 12, $labelposition, 144, 36); Other position labels
            GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    EndSwitch
    $positionarray[$i][1] = 0; Button states
    $labelposition += 41
Next
SetBitmap($ImageGUI, $MainSkin, 255)

; TEXT GUI
$ControlGUI = GUICreate("ControlGUI", $Width, $Height, $pl_pos[0], $pl_pos[1], $WS_POPUP, $WS_EX_LAYERED + $WS_EX_COMPOSITED, $ImageGUI)
GUISetFont(11, 400, -1, "Comic Sans MS")
GUISetBkColor(0x003842, $ControlGUI)
$textposition = 9
For $i = 1 To 12; Button text labels
    Switch $i
        Case 11
            $textarray[$i] = GUICtrlCreateLabel("", 19, $textposition + 5, 91, 13, BitOR($SS_CENTER, $SS_CENTERIMAGE)); Status label
            GUICtrlSetFont(-1, 8)
        Case 12
            $textarray[$i] = GUICtrlCreateLabel("", 19, $textposition - 24, 91, 13, BitOR($SS_CENTER, $SS_CENTERIMAGE)); Usage label
            GUICtrlSetFont(-1, 8)
        Case Else
            $textarray[$i] = GUICtrlCreateLabel("", 21, $textposition + 6, 128, 25, $SS_CENTERIMAGE)
            GUICtrlSetState(-1, $GUI_ONTOP)
            $icon[$i] = GUICtrlCreatePic("", 125, $textposition + 7, 24, 24)
            GUICtrlSetState(-1, $GUI_DISABLE)
            $input[$i] = GUICtrlCreateInput("", 23, $textposition + 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)
    $textposition += 41
Next
$default_button = GUICtrlCreateButton("", 30, $Height + 35, 5, 5, $BS_DEFPUSHBUTTON)
_WinAPI_SetLayeredWindowAttributes($ControlGUI, 0x003842, 255)

; JUMPLIST GUI
$JumplistMGUI = GUICreate("", 220, 299, $DesktopWidth, $DesktopHeight, $WS_POPUP, $WS_EX_LAYERED, $ImageGUI)
SetBitmap($JumplistMGUI, $Jumplist_BG, 255)
_GDIPlus_ImageDispose($Jumplist_BG)
GUISetState(@SW_HIDE, $JumplistMGUI)
$JumplistTextGUI = GUICreate("ControlGUI", 220, 299, $DesktopWidth, $DesktopHeight, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_COMPOSITED, $JumplistMGUI)
GUISetBkColor(0x003842, $JumplistTextGUI)
$JumplistLabelArraytitle = GUICtrlCreateLabel("", 21, 19, 175, 20, 0x0C)
GUICtrlSetFont(-1, 11, 400, 4, "Arial")
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$jump_icon = GUICtrlCreatePic("", 174, 13, 32, 32)
GUICtrlSetState(-1, $GUI_DISABLE)
$jump_top = 37
For $i = 1 To 15
    $JumplistLabelArray[$i][0] = GUICtrlCreateLabel("", 21, $jump_top, 176, 16, 0x0C)
    $JumplistLabelArray[$i][1] = 0; Button states
    GUICtrlSetColor(-1, 0xffffff)
    GUICtrlSetFont(-1, 10, 400, 0, "Arial")
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetState(-1, $GUI_ONTOP)
    $jump_top += 16
Next
_WinAPI_SetLayeredWindowAttributes($JumplistTextGUI, 0x003842, 255)

GUISetState(@SW_SHOW, $ImageGUI)
GUISetState(@SW_SHOW, $ControlGUI)
GUISetState(@SW_HIDE, $JumplistTextGUI)

Load_TextAndIcons()
;~ LoadNetChecking()
;~ GetNetStatus()

TrayTip("Playlet's Launcher", "", 0)

ShowOrHideGUI("Hide")
_ReduceMemory(@AutoItPID)
AdlibRegister("CPUUsage", 1000)

While 1
    Switch Activate_Gui(MouseGetPos())
        Case True
            ShowOrHideGUI("Show")
            While Activate_Gui(MouseGetPos()) = True
                $pos = GUIGetCursorInfo($ImageGUI)
                Switch $pos[2]
                    Case 1; left mouse button pressed - add files to the list OR drag both guis to change position
                        Switch $pos[3]
                            Case 1; drag mode - left and mouse button must be pressed at the same time to change launcher position
                                Drag_Mode()
                                ExitLoop
                            Case 0; config mode - only left mouse button pressed (dragging files / folders)
                                If $pos[4] <> 0 And $pos[4] <> $positionarray[11][0] Then
                                    TraySetIcon(@TempDir & "\PL-essential\config_pause_icons.icl", 1)
                                    GUIRegisterMsg(0x0233, "WM_DROPFILES_FUNC")
                                    While $pos[4] <> 0 And $pos[4] <> $positionarray[11][0]
                                        $pos = GUIGetCursorInfo($ImageGUI)
                                        Switch GUIGetMsg($ImageGUI)
                                            Case $GUI_EVENT_DROPPED
                                                Poof_splash()
                                                $selection = ""
                                                For $i = 1 To 10
                                                    If $pos[4] = $positionarray[$i][0] Then $selection = $i
                                                Next
                                                Configuration($selection)
                                        EndSwitch
                                        Sleep(10)
                                    WEnd
                                    TraySetIcon(@TempDir & "\PL-essential\devilish.ico")
                                    GUIRegisterMsg(0x0233, "")
                                EndIf
                        EndSwitch
                    Case Else; Button checking part
                        For $i = 1 To 11
                            Switch $pos[4]
                                Case $positionarray[$i][0]
                                    If $pos[3] = 1 Then ExitLoop
                                    While $pos[4] = $positionarray[$i][0]
                                        $pos = GUIGetCursorInfo($ImageGUI)
                                        Switch $pos[3]
                                            Case 1; RIGHT CLICKED
                                                If $i < 11 Then
                                                    ShowJumplistGUI($i)
                                                    $msgpos = GUIGetCursorInfo($JumplistTextGUI)
                                                    While Activate_Jumplist($msgpos, GUIGetCursorInfo($ImageGUI), $pos[4]) = True
                                                        $msgpos = GUIGetCursorInfo($JumplistTextGUI)
                                                        For $d = 1 To 15
                                                            Switch $msgpos[4]
                                                                Case $JumplistLabelArray[$d][0]
                                                                    While $msgpos[4] = $JumplistLabelArray[$d][0]
                                                                        $msgpos = GUIGetCursorInfo($JumplistTextGUI)
                                                                        Switch $msgpos[2]
                                                                            Case 0
                                                                                If $JumplistLabelArray[$d][1] <> 1 Then
                                                                                    GUICtrlSetColor($JumplistLabelArray[$d][0], 0x00adff)
                                                                                    $JumplistLabelArray[$d][1] = 1
                                                                                EndIf
                                                                            Case 1
                                                                                While $msgpos[2] = 1
                                                                                    $msgpos = GUIGetCursorInfo($JumplistTextGUI)
                                                                                    Switch $msgpos[4]
                                                                                        Case $JumplistLabelArray[$d][0]
                                                                                            If $JumplistLabelArray[$d][1] <> 2 Then
                                                                                                GUICtrlSetColor($JumplistLabelArray[$d][0], 0xfa5000)
                                                                                                $JumplistLabelArray[$d][1] = 2
                                                                                            EndIf
                                                                                        Case Else
                                                                                            If $JumplistLabelArray[$d][1] <> 3 Then
                                                                                                GUICtrlSetColor($JumplistLabelArray[$d][0], 0x00adff)
                                                                                                $JumplistLabelArray[$d][1] = 3
                                                                                            EndIf
                                                                                    EndSwitch
                                                                                    Sleep(10)
                                                                                WEnd
                                                                                If $msgpos[4] = $JumplistLabelArray[$d][0] Then RunIt($i, $d)
                                                                                If GUICtrlRead($JumplistLabelArray[$d][0]) <> "" And $msgpos[0] < -5 Or $msgpos[0] > 225 Or $msgpos[1] < -5 Or $msgpos[1] > 304 Then
                                                                                    Poof_splash()
                                                                                    $question = MsgBox(4 + 48, "Playlet's Launcher", "Warning!" & @CRLF & @CRLF & 'You are about to delete item "' & StringTrimLeft(GUICtrlRead($JumplistLabelArray[$d][0]), 2) & '" from button "' & GUICtrlRead($textarray[$i]) & '".' & @CRLF & @CRLF & "Are you sure you want to do this?")
                                                                                    If $question = 6 Then DeleteItem($i, $d)
                                                                                EndIf
                                                                                ExitLoop
                                                                        EndSwitch
                                                                        Sleep(10)
                                                                    WEnd
                                                                    GUICtrlSetColor($JumplistLabelArray[$d][0], 0xffffff)
                                                                    $JumplistLabelArray[$d][1] = 0
                                                            EndSwitch
                                                        Next
                                                        Sleep(10)
                                                    WEnd
                                                    HideJumplistGUI()
                                                    _ReduceMemory(@AutoItPID)
                                                EndIf
                                            Case Else
                                                Switch $pos[2]
                                                    Case 0; Not pressed
                                                        If $positionarray[$i][1] <> 1 Then
                                                            SetBitmap($ImageGUI, $over[$i], 255)
                                                            If $i < 11 Then
                                                                GUICtrlSetFont($textarray[$i], 11.5)
                                                                GUICtrlSetColor($textarray[$i], 0x00adff)
                                                            EndIf
                                                            $positionarray[$i][1] = 1
                                                        EndIf
                                                    Case 1; Pressed
                                                        While $pos[2] = 1; Holding pressed
                                                            $pos = GUIGetCursorInfo($ImageGUI)
                                                            Switch $pos[4]
                                                                Case $positionarray[$i][0]; On button
                                                                    If $positionarray[$i][1] <> 2 Then
                                                                        SetBitmap($ImageGUI, $pressed[$i], 255)
                                                                        If $i < 11 Then
                                                                            GUICtrlSetFont($textarray[$i], 12)
                                                                            GUICtrlSetColor($textarray[$i], 0xfa5000)
                                                                        EndIf
                                                                        $positionarray[$i][1] = 2
                                                                    EndIf
                                                                Case Else; Not on button
                                                                    If $positionarray[$i][1] <> 3 Then
                                                                        SetBitmap($ImageGUI, $over[$i], 255)
                                                                        If $i < 11 Then
                                                                            GUICtrlSetFont($textarray[$i], 11.5)
                                                                            GUICtrlSetColor($textarray[$i], 0x00adff)
                                                                        EndIf
                                                                        $positionarray[$i][1] = 3
                                                                    EndIf
                                                            EndSwitch
                                                            Sleep(10)
                                                        WEnd
                                                        If $pos[4] = $positionarray[$i][0] Then RunIt($i); Still on the control after release
                                                        If $i < 11 And GUICtrlRead($textarray[$i]) <> "" And $pos[0] < -5 Or $pos[0] > $Width + 5 Or $pos[1] < -5 Or $pos[1] > $Height + 5 Then
                                                            Poof_splash()
                                                            $question = MsgBox(4 + 48, "Playlet's Launcher", "Warning!" & @CRLF & @CRLF & 'You are about to delete all settings for ' & '"' & GUICtrlRead($textarray[$i]) & '"' & " button" & @CRLF & @CRLF & "Are you sure you want to do this?")
                                                            If $question = 6 Then Clear_Button($i)
                                                        EndIf
                                                EndSwitch
                                        EndSwitch
                                        Sleep(10)
                                    WEnd
                                    If $i < 11 Then
                                        GUICtrlSetFont($textarray[$i], 11)
                                        GUICtrlSetColor($textarray[$i], 0xffffff)
                                    EndIf
                                    SetBitmap($ImageGUI, $MainSkin, 255)
                                    $positionarray[$i][1] = 0
                                Case Else
;~                                  If TimerDiff($timer) >= 1000 Then
;~                                      CPUUsage()
;~                                      GetNetStatus(); Update status fields only when not over the control and every 2,5 sec - reduces usage
;~                                      $timer = TimerInit()
;~                                  EndIf
                                    If TimerDiff($MemTimer) > 9000 Then
                                        _ReduceMemory(@AutoItPID)
                                        $MemTimer = TimerInit()
                                    EndIf
                            EndSwitch
                        Next; End of button checking part
                EndSwitch
                Sleep(10)
            WEnd
            ShowOrHideGUI("Hide")
            _ReduceMemory(@AutoItPID)
        Case Else
            Switch TrayGetMsg()
                Case $tray_mode
                    TrayItemSetState($tray_mode, 1)
                    Pause_Mode()
                    TrayItemSetState($tray_mode, 4)
                Case $tray_check
                    Checkfiles()
                Case $tray_instr
                    Instructions()
                Case $tray_about
                    MsgBox(64, "Playlet's Launcher", "version 4.0.2.8" & @CRLF & @CRLF & "Made by Playlet, 2010")
                Case $tray_exit
                    Exit
            EndSwitch
    EndSwitch
    Sleep(20)
WEnd

Func CPUUsage()
    If Not Activate_Gui(MouseGetPos()) Then Return
    If $bFirstRun Then
        Local $CPU = _ProcessCalc()
        Return
    Else
        Local $CPU = _ProcessCalc()
    EndIf

    GUICtrlSetData($textarray[11], "CPU Usage")
    GUICtrlSetData($textarray[12], $CPU)
EndFunc   ;==>CPUUsage

Func _ProcessCalc()
    Local $tProcess, $tSystem, $tSystemt, $hScripthandle = _WinAPI_GetCurrentProcess()
    Local $IDLETIME = DllStructCreate($tagFILETIME), $KERNELTIME = DllStructCreate($tagFILETIME), $USERTIME = DllStructCreate($tagFILETIME)
    Local $PCreationTime = DllStructCreate($tagFILETIME), $PExitTime = DllStructCreate($tagFILETIME), $PKernelTime = DllStructCreate($tagFILETIME), $PUserTime = DllStructCreate($tagFILETIME)
    DllCall('Kernel32.dll', "int", "GetSystemTimes", "ptr", DllStructGetPtr($IDLETIME), "ptr", DllStructGetPtr($KERNELTIME), "ptr", DllStructGetPtr($USERTIME))
    DllCall('Kernel32.dll', "int", "GetProcessTimes", "hwnd", $hScripthandle, "ptr", DllStructGetPtr($PCreationTime), "ptr", DllStructGetPtr($PExitTime), "ptr", DllStructGetPtr($PKernelTime), "ptr", DllStructGetPtr($PUserTime))
    If Not $bFirstRun Then
        $tProcess = (DllStructGetData($PKernelTime, 1) - $ProcStartKern) + (DllStructGetData($PUserTime, 1) - $ProcStartUser)
        $tSystem = (DllStructGetData($KERNELTIME, 1) - $StartKernel) + (DllStructGetData($USERTIME, 1) - $StartUser)
        $tSystemt = (($tSystem - (DllStructGetData($IDLETIME, 1) - $StartIdle)) * (100 / $tSystem))
    EndIf
    $ProcStartKern = DllStructGetData($PKernelTime, 1)
    $ProcStartUser = DllStructGetData($PUserTime, 1)
    $StartIdle = DllStructGetData($IDLETIME, 1)
    $StartKernel = DllStructGetData($KERNELTIME, 1)
    $StartUser = DllStructGetData($USERTIME, 1)
    If $bFirstRun Then $bFirstRun = False
    $ProcessCpu = ($tProcess / $tSystem) * 100
    $TotalCpu = $tSystemt

    Return Round($ProcessCpu, 0)
EndFunc   ;==>_ProcessCalc

Func Activate_Jumplist($cursorjump, $imageguicursor, $lastcontrol)
    Switch $Side_choice
        Case "Right"
            Select
                Case $cursorjump[0] < -20 Or $cursorjump[1] < -20 Or $cursorjump[1] > 319
                    Return False
                Case Else
                    If $cursorjump[0] > 240 And $imageguicursor[4] <> $lastcontrol Then Return False
            EndSelect
        Case "Left"
            Select
                Case $cursorjump[0] > 240 Or $cursorjump[1] < -20 Or $cursorjump[1] > 319
                    Return False
                Case Else
                    If $cursorjump[0] < -20 And $imageguicursor[4] <> $lastcontrol Then Return False
            EndSelect
        Case Else
            Select
                Case $pl_pos[0] > $DesktopWidth - $Width - 220
                    Select
                        Case $cursorjump[0] < -20 Or $cursorjump[1] < -20 Or $cursorjump[1] > 319
                            Return False
                        Case Else
                            If $cursorjump[0] > 240 And $imageguicursor[4] <> $lastcontrol Then Return False
                    EndSelect
                Case $pl_pos[0] < $Width + 220
                    Select
                        Case $cursorjump[0] > 240 Or $cursorjump[1] < -20 Or $cursorjump[1] > 319
                            Return False
                        Case Else
                            If $cursorjump[0] < -20 And $imageguicursor[4] <> $lastcontrol Then Return False
                    EndSelect
                Case Else
                    Select
                        Case $cursorjump[0] > 240 Or $cursorjump[1] < -20 Or $cursorjump[1] > 319
                            Return False
                        Case Else
                            If $cursorjump[0] < -20 And $imageguicursor[4] <> $lastcontrol Then Return False
                    EndSelect
            EndSelect
    EndSwitch
    Return True
EndFunc   ;==>Activate_Jumplist

Func Pause_Mode()
    TraySetIcon(@TempDir & "\PL-essential\config_pause_icons.icl", 2)
    While 1
        Switch TrayGetMsg()
            Case $tray_mode
                ExitLoop
            Case $tray_check
                MsgBox(64, "Playlet's Launcher", "This action is unavailable during Pause Mode.")
            Case $tray_instr
                Instructions()
            Case $tray_about
                MsgBox(64, "Playlet's Launcher", "version 4.0.2.8" & @CRLF & @CRLF & "Made by Playlet, 2010")
            Case $tray_exit
                Exit
        EndSwitch
        Sleep(25)
    WEnd
    TraySetIcon(@TempDir & "\PL-essential\devilish.ico")
EndFunc   ;==>Pause_Mode

Func Startup_Settings()
    If FileExists($ini_file) Then
        $pl_pos[0] = IniRead($ini_file, "Global_position", "X", "")
        $pl_pos[1] = IniRead($ini_file, "Global_position", "Y", "")
        $Side_choice = IniRead($ini_file, "Global_position", "Mode", "")
        Checkfiles()
    Else
        $Side_choice = "Right"
        $pl_pos[0] = $DesktopWidth - $Width
        $pl_pos[1] = $DesktopHeight - $Height - 100
        IniWrite($ini_file, "Global_position", "Mode", "Right")
        IniWrite($ini_file, "Global_position", "X", $DesktopWidth - $Width)
        IniWrite($ini_file, "Global_position", "Y", $DesktopHeight - $Height - 100)
        For $i = 1 To 10
            IniWrite($ini_file, "PL-Button_" & $i, "Main_title", "")
            IniWrite($ini_file, "PL-Button_" & $i, "File_type", "")
            IniWrite($ini_file, "PL-Button_" & $i, "Count", 0)
            For $j = 1 To 15
                IniWrite($ini_file, "PL-Button_" & $i, $j, "")
            Next
        Next
    EndIf
    Calc_Best_Pos()
EndFunc   ;==>Startup_Settings

Func Configuration($choice)
    Local $real_array[16], $counter = 0, $real_count = 0, $proceed = "no"
    If $DropFilesArray[0] > 0 Then
        $read_bcount = IniRead($ini_file, "PL-Button_" & $choice, "Count", "")
        If $read_bcount = 0 Then
            $maintype = Determine_FileType($DropFilesArray[1])
            IniWrite($ini_file, "PL-Button_" & $choice, "File_type", $maintype)
        Else
            $maintype = IniRead($ini_file, "PL-Button_" & $choice, "File_type", "")
        EndIf
        For $i = 1 To $DropFilesArray[0]
            If $maintype = Determine_FileType($DropFilesArray[$i]) Then
                $real_count += 1
                If UBound($real_array) >= $real_count Then ReDim $real_array[$real_count + 1]
                $real_array[$real_count] = $DropFilesArray[$i]
            EndIf
        Next
        If $real_count = 0 Then
            MsgBox(48, "Playlet's Launcher", "These files do not match required file type")
        Else
            If $real_count <= 15 - $read_bcount Then
                For $i = $read_bcount + 1 To $read_bcount + $real_count
                    $counter += 1
                    IniWrite($ini_file, "PL-Button_" & $choice, $i, $real_array[$counter])
                Next
                IniWrite($ini_file, "PL-Button_" & $choice, "Count", $read_bcount + $real_count)
                $proceed = "yes"
            Else
                MsgBox(48, "Playlet's Launcher", "Number of valid files exceeds button's free space")
            EndIf
        EndIf
        If $read_bcount = 0 And $proceed = "yes" Then
            GUICtrlSetImage($icon[$choice], "")
            GUICtrlSetState($textarray[$choice], $GUI_HIDE)
            GUICtrlSetState($input[$choice], $GUI_SHOW)
            GUICtrlSetData($input[$choice], "Saved, enter text")
            GUICtrlSetState($input[$choice], $GUI_FOCUS)
            While 1
                Switch GUIGetMsg()
                    Case $default_button; ENTER key
                        If WinActive($ControlGUI) Then
                            $readinput = GUICtrlRead($input[$choice])
                            If $readinput = "" Or $readinput = "Saved, enter text" Then
                                MsgBox(48, "Playlet's Launcher", "You can't leave the text field empty!" & @CRLF & "Please enter text")
                                GUICtrlSetState($input[$choice], $GUI_FOCUS)
                            Else
                                GUICtrlSetData($textarray[$choice], $readinput)
                                IniWrite($ini_file, "PL-Button_" & $choice, "Main_title", $readinput)
                                GUICtrlSetState($input[$choice], $GUI_HIDE)
                                GUICtrlSetState($textarray[$choice], $GUI_SHOW)
                                Set_Icon($icon[$choice], $choice)
                                ExitLoop
                            EndIf
                        EndIf
                EndSwitch
                Sleep(10)
            WEnd
        EndIf
        Checkfiles($choice)
    EndIf
EndFunc   ;==>Configuration

Func SortValidFiles($num)
    Local $filearray[16], $realarray[16], $realcount = 0
    For $i = 1 To 15
        $filearray[$i] = IniRead($ini_file, "PL-Button_" & $num, $i, "")
    Next
    For $i = 1 To 15
        If $filearray[$i] <> "" And FileExists($filearray[$i]) Then
            $realcount += 1
            $realarray[$realcount] = $filearray[$i]
        EndIf
    Next
    For $i = $realcount + 1 To 15
        $realarray[$i] = ""
    Next
    _ArraySort($realarray, 0, 1, $realcount)
    If $realcount > 0 Then
        IniWrite($ini_file, "PL-Button_" & $num, "Count", $realcount)
        For $i = 1 To $realcount
            IniWrite($ini_file, "PL-Button_" & $num, $i, $realarray[$i])
        Next
        For $i = $realcount + 1 To 15
            IniWrite($ini_file, "PL-Button_" & $num, $i, "")
        Next
    Else
        IniWrite($ini_file, "PL-Button_" & $num, "File_type", "")
        IniWrite($ini_file, "PL-Button_" & $num, "Main_title", "")
        IniWrite($ini_file, "PL-Button_" & $num, "Count", 0)
        For $i = 1 To 15
            IniWrite($ini_file, "PL-Button_" & $num, $i, "")
        Next
        GUICtrlSetData($textarray[$num], "")
        GUICtrlSetImage($icon[$num], "")
    EndIf
EndFunc   ;==>SortValidFiles

Func Checkfiles($number_i = "")
    TrayTip("Playlet's Launcher", "Please wait, checking/sorting button items.", 0, 1)
    Switch $number_i
        Case ""
            For $i = 1 To 10
                SortValidFiles($i)
            Next
        Case Else
            SortValidFiles($number_i)
    EndSwitch
    TrayTip("Playlet's Launcher", "", 0)
EndFunc   ;==>Checkfiles

Func ExitProgram()
    _GDIPlus_BitmapDispose($MainSkin)
    For $i = 1 To 11
        _GDIPlus_BitmapDispose($over[$i])
        _GDIPlus_BitmapDispose($pressed[$i])
    Next
    _GDIPlus_Shutdown()
    DirRemove(@TempDir & "\PL-essential", 1)
EndFunc   ;==>ExitProgram

Func WM_MOVE()
    Local $MainWindowPosition = WinGetPos($ImageGUI), $ihoriz_pos, $ivert_pos
    Select
        Case $MainWindowPosition[0] < 60
            $ihoriz_pos = 5
            $ivert_pos = $MainWindowPosition[1]
            $Side_choice = "Left"
        Case ($MainWindowPosition[0] + $MainWindowPosition[2]) > $DesktopWidth - 60
            $ihoriz_pos = $DesktopWidth - $Width - 5
            $ivert_pos = $MainWindowPosition[1]
            $Side_choice = "Right"
        Case $MainWindowPosition[1] < 60
            $ihoriz_pos = $MainWindowPosition[0]
            $ivert_pos = 5
            $Side_choice = "Up"
        Case ($MainWindowPosition[1] + $MainWindowPosition[3]) > $DesktopHeight - 60
            $ihoriz_pos = $MainWindowPosition[0]
            $ivert_pos = $DesktopHeight - $Height - 5
            $Side_choice = "Down"
        Case Else
            $ihoriz_pos = $MainWindowPosition[0]
            $ivert_pos = $MainWindowPosition[1]
            $Side_choice = "Default"
    EndSelect
    WinMove($ControlGUI, "", $ihoriz_pos, $ivert_pos)
    WinMove($ImageGUI, "", $ihoriz_pos, $ivert_pos)
    Sleep(1)
EndFunc   ;==>WM_MOVE

Func Set_Icon($control_choice, $number, $icon_size = 24)
    Local $iniread = IniRead($ini_file, "PL-Button_" & $number, 1, ""), $hIcon, $h_Bitmap
    If $iniread <> "" And FileExists($iniread) Then
        If StringInStr(FileGetAttrib($iniread), "d") Then
            $hIcon = _Icons_Icon_Extract(@WindowsDir & "\explorer.exe", 13, $icon_size, $icon_size)
        Else
            $splitname = StringSplit($iniread, ".", 1)
            Switch $splitname[$splitname[0]]
                Case "exe"
                    $hIcon = _Icons_Icon_Extract($iniread, 0, $icon_size, $icon_size)
                Case Else
                    $iconpath = RetrieveIconPath($iniread)
                    $hIcon = _Icons_Icon_Extract($iconpath[0], $iconpath[1], $icon_size, $icon_size)
            EndSwitch
        EndIf
        $h_Bitmap = _Icons_Bitmap_CreateFromIcon($hIcon)
        _SetHImage($control_choice, $h_Bitmap)
        _WinAPI_DeleteObject($h_Bitmap)
        _WinAPI_DestroyIcon($hIcon)
    EndIf
EndFunc   ;==>Set_Icon

Func Poof_splash()
    Local $Poof_PNG = _GDIPlus_ImageLoadFromFile(@TempDir & "\PL-essential\Poof.png")
    Local $SplashGUI_On = GUICreate("", 128, 128, MouseGetPos(0) - 60, MouseGetPos(1) - 60, $WS_POPUP, $WS_EX_LAYERED, $ImageGUI)
    GUISetState(@SW_SHOW, $SplashGUI_On)
    WinSetOnTop($SplashGUI_On, "", 1)
    $Top = 0
    For $i = 1 To 5
        $Poof = _GDIPlus_BitmapCloneArea($Poof_PNG, 0, $Top, 128, 128, $GDIP_PXF32ARGB)
        SetBitmap($SplashGUI_On, $Poof, 255)
        _GDIPlus_ImageDispose($Poof)
        $Top += 128
        Sleep(35)
    Next
    GUIDelete($SplashGUI_On)
    _GDIPlus_ImageDispose($Poof_PNG)
EndFunc   ;==>Poof_splash

Func Drag_Mode()
    GUIRegisterMsg($WM_MOVE, "WM_MOVE")
    _SendMessage($ImageGUI, $WM_SYSCOMMAND, 0xF012, 0)
    Local $MainWindowPosition2 = WinGetPos($ImageGUI)
    GUIRegisterMsg($WM_MOVE, "")
    If $Side_choice = "Default" Then
        $Side_choice = "Right"
        $MainWindowPosition2[0] = $DesktopWidth - $Width
        $MainWindowPosition2[1] = $DesktopHeight - $Height - 100
    EndIf
    IniWrite($ini_file, "Global_position", "Mode", $Side_choice)
    IniWrite($ini_file, "Global_position", "X", $MainWindowPosition2[0])
    IniWrite($ini_file, "Global_position", "Y", $MainWindowPosition2[1])
    $pl_pos[0] = $MainWindowPosition2[0]
    $pl_pos[1] = $MainWindowPosition2[1]
    Calc_Best_Pos()
EndFunc   ;==>Drag_Mode

Func Load_JumplistItems($inumber, $countitems)
    $gettype = IniRead($ini_file, "PL-Button_" & $inumber, "File_type", "")
    Switch $gettype
        Case "FOLDERS"
            GUICtrlSetData($JumplistLabelArraytitle, "FOLDERS                  ")
        Case Else
            GUICtrlSetData($JumplistLabelArraytitle, StringUpper($gettype) & " files            ")
    EndSwitch
    For $i = 1 To $countitems
        Switch $gettype
            Case "FOLDERS"
                $lastsection = StringSplit(IniRead($ini_file, "PL-Button_" & $inumber, $i, ""), "\", 1)
                GUICtrlSetData($JumplistLabelArray[$i][0], "- " & $lastsection[$lastsection[0]])
            Case Else
                $lastsection = StringSplit(IniRead($ini_file, "PL-Button_" & $inumber, $i, ""), "\", 1)
                $splitname = StringSplit($lastsection[$lastsection[0]], ".", 1)
                $extensionlength = StringLen($splitname[$splitname[0]]) + 1
                $filetextnoextension = StringTrimRight($lastsection[$lastsection[0]], $extensionlength)
                GUICtrlSetData($JumplistLabelArray[$i][0], "- " & $filetextnoextension)
        EndSwitch
    Next
    Set_Icon($jump_icon, $inumber, 32)
EndFunc   ;==>Load_JumplistItems

Func Load_TextAndIcons()
    For $i = 1 To 10
        GUICtrlSetData($textarray[$i], IniRead($ini_file, "PL-Button_" & $i, "Main_title", ""))
        Set_Icon($icon[$i], $i)
    Next
EndFunc   ;==>Load_TextAndIcons

Func DeleteItem($buttonno, $itemno)
    IniWrite($ini_file, "PL-Button_" & $buttonno, $itemno, "")
    Checkfiles($buttonno)
EndFunc   ;==>DeleteItem

Func Clear_Button($which)
    GUICtrlSetData($textarray[$which], "")
    GUICtrlSetImage($icon[$which], "")
    IniWrite($ini_file, "PL-Button_" & $which, "Count", 0)
    IniWrite($ini_file, "PL-Button_" & $which, "File_type", "")
    IniWrite($ini_file, "PL-Button_" & $which, "Main_title", "")
    For $i = 1 To 15
        IniWrite($ini_file, "PL-Button_" & $which, $i, "")
    Next
EndFunc   ;==>Clear_Button

Func ShowJumplistGUI($buttonnumber)
    Local $count_JLitems = IniRead($ini_file, "PL-Button_" & $buttonnumber, "Count", ""), $vertical_pos, $horizontal_pos
    Local $controlpos = ControlGetPos($ImageGUI, "", $positionarray[$buttonnumber][0])
    If $count_JLitems > 0 Then
        Select
            Case $controlpos[1] < 89
                $vertical_pos = 135 + $pl_pos[1] - 135
            Case $controlpos[1] > 89 And $controlpos[1] < 171
                $vertical_pos = 167 + $pl_pos[1] - 135
            Case $controlpos[1] > 171 And $controlpos[1] < 253
                $vertical_pos = 199 + $pl_pos[1] - 135
            Case $controlpos[1] > 253 And $controlpos[1] < 335
                $vertical_pos = 231 + $pl_pos[1] - 135
            Case $controlpos[1] > 335
                $vertical_pos = 262 + $pl_pos[1] - 135
        EndSelect
        Switch $Side_choice
            Case "Right"
                $horizontal_pos = $pl_pos[0] - 203
            Case "Left"
                $horizontal_pos = $pl_pos[0] + $Width - 14
            Case Else
                Select
                    Case $pl_pos[0] > $DesktopWidth - $Width - 220
                        $horizontal_pos = $pl_pos[0] - 203
                    Case $pl_pos[0] < $Width + 220
                        $horizontal_pos = $pl_pos[0] + $Width - 14
                    Case Else
                        $horizontal_pos = $pl_pos[0] + $Width - 14
                EndSelect
        EndSwitch
        WinMove($JumplistMGUI, "", $horizontal_pos, $vertical_pos)
        WinMove($JumplistTextGUI, "", $horizontal_pos, $vertical_pos)
        GUISetState(@SW_SHOW, $JumplistMGUI)
        GUISetState(@SW_SHOW, $JumplistTextGUI)
        Load_JumplistItems($buttonnumber, $count_JLitems)
    EndIf
EndFunc   ;==>ShowJumplistGUI

Func Calc_Best_Pos()
    Local $aTray = WinGetPos("[CLASS:Shell_TrayWnd]"), $taskbarpos = ""
    $Up_sens = 0
    $Down_sens = 0
    $Left_sens = 0
    $Right_sens = 0
    If $aTray[0] < Ceiling($DesktopWidth / 2) Then
        If $aTray[1] > Ceiling($DesktopHeight / 2) Then
            $taskbarpos = "Down"
        Else
            If $aTray[2] < Ceiling($DesktopWidth / 2) Then
                $taskbarpos = "Left"
            Else
                $taskbarpos = "Up"
            EndIf
        EndIf
    Else
        $taskbarpos = "Right"
    EndIf
    If $taskbarpos = "Up" And $Side_choice = "Up" Then $Up_sens = $aTray[3]
    If $taskbarpos = "Down" And $Side_choice = "Down" Then $Down_sens = $aTray[3]
    If $taskbarpos = "Left" And $Side_choice = "Left" Then $Left_sens = $aTray[2]
    If $taskbarpos = "Right" And $Side_choice = "Right" Then $Right_sens = $aTray[2]
EndFunc   ;==>Calc_Best_Pos

Func Determine_FileType($ifile)
    If StringInStr(FileGetAttrib($ifile), "d") Then
        Return "FOLDERS"
    Else
        $getext = StringSplit($ifile, ".", 1)
        Return $getext[$getext[0]]
    EndIf
EndFunc   ;==>Determine_FileType

Func Activate_Gui($i_xy)
    Switch $Side_choice
        Case "Up"
            Switch $PL_Launcher_state
                Case "Hidden"
                    If $i_xy[1] < $SGSens And $i_xy[0] > $pl_pos[0] - 5 And $i_xy[0] < $pl_pos[0] + $Width + 5 Then
                        $PL_Launcher_state = "Shown"
                        Return True
                    EndIf
                Case "Shown"
                    If $i_xy[0] > $pl_pos[0] - 35 And $i_xy[0] < $pl_pos[0] + $Width + 35 And $i_xy[1] > $pl_pos[1] - 35 And $i_xy[1] < $pl_pos[1] + $Height + 35 Then Return True
            EndSwitch
        Case "Down"
            Switch $PL_Launcher_state
                Case "Hidden"
                    If $i_xy[1] > $DesktopHeight - $SGSens And $i_xy[0] > $pl_pos[0] - 5 And $i_xy[0] < $pl_pos[0] + $Width + 5 Then
                        $PL_Launcher_state = "Shown"
                        Return True
                    EndIf
                Case "Shown"
                    If $i_xy[0] > $pl_pos[0] - 35 And $i_xy[0] < $pl_pos[0] + $Width + 35 And $i_xy[1] > $pl_pos[1] - 35 And $i_xy[1] < $pl_pos[1] + $Height + 35 Then Return True
            EndSwitch
        Case "Left"
            Switch $PL_Launcher_state
                Case "Hidden"
                    If $i_xy[0] < $SGSens And $i_xy[1] > $pl_pos[1] - 5 And $i_xy[1] < $pl_pos[1] + $Height + 5 Then
                        $PL_Launcher_state = "Shown"
                        Return True
                    EndIf
                Case "Shown"
                    If $i_xy[0] > $pl_pos[0] - 35 And $i_xy[0] < $pl_pos[0] + $Width + 35 And $i_xy[1] > $pl_pos[1] - 35 And $i_xy[1] < $pl_pos[1] + $Height + 35 Then Return True
            EndSwitch
        Case "Right"
            Switch $PL_Launcher_state
                Case "Hidden"
                    If $i_xy[0] > $DesktopWidth - $SGSens And $i_xy[1] > $pl_pos[1] - 5 And $i_xy[1] < $pl_pos[1] + $Height + 5 Then
                        $PL_Launcher_state = "Shown"
                        Return True
                    EndIf
                Case "Shown"
                    If $i_xy[0] > $pl_pos[0] - 35 And $i_xy[0] < $pl_pos[0] + $Width + 35 And $i_xy[1] > $pl_pos[1] - 35 And $i_xy[1] < $pl_pos[1] + $Height + 35 Then Return True
            EndSwitch
    EndSwitch
    $PL_Launcher_state = "Hidden"
    Return False
EndFunc   ;==>Activate_Gui

Func ShowOrHideGUI($what_to_do)
    Switch $what_to_do
        Case "Show"
            GUISetState(@SW_SHOW, $ImageGUI)
            GUISetState(@SW_SHOW, $ControlGUI)
            Switch $Side_choice
                Case "Up"
                    For $i = -($Height) To $Up_sens Step 11
                        WinMove($ImageGUI, "", $pl_pos[0], $i)
                        WinMove($ControlGUI, "", $pl_pos[0], $i)
                    Next
                Case "Down"
                    For $i = $DesktopHeight To $DesktopHeight - $Height - $Down_sens Step -11
                        WinMove($ImageGUI, "", $pl_pos[0], $i)
                        WinMove($ControlGUI, "", $pl_pos[0], $i)
                    Next
                Case "Left"
                    For $i = -($Width) To $Left_sens Step 11
                        WinMove($ImageGUI, "", $i, $pl_pos[1])
                        WinMove($ControlGUI, "", $i, $pl_pos[1])
                    Next
                Case "Right"
                    For $i = $DesktopWidth To $DesktopWidth - $Width - $Right_sens Step -11
                        WinMove($ImageGUI, "", $i, $pl_pos[1])
                        WinMove($ControlGUI, "", $i, $pl_pos[1])
                    Next
            EndSwitch
        Case "Hide"
            Switch $Side_choice
                Case "Up"
                    For $i = $Up_sens To -($Height) Step -11
                        WinMove($ImageGUI, "", $pl_pos[0], $i)
                        WinMove($ControlGUI, "", $pl_pos[0], $i)
                    Next
                Case "Down"
                    For $i = $DesktopHeight - $Height - $Down_sens To $DesktopHeight Step 11
                        WinMove($ImageGUI, "", $pl_pos[0], $i)
                        WinMove($ControlGUI, "", $pl_pos[0], $i)
                    Next
                Case "Left"
                    For $i = $Left_sens To -($Width) Step -11
                        WinMove($ImageGUI, "", $i, $pl_pos[1])
                        WinMove($ControlGUI, "", $i, $pl_pos[1])
                    Next
                Case "Right"
                    For $i = $DesktopWidth - $Width - $Right_sens To $DesktopWidth Step 11
                        WinMove($ImageGUI, "", $i, $pl_pos[1])
                        WinMove($ControlGUI, "", $i, $pl_pos[1])
                    Next
            EndSwitch
            GUISetState(@SW_HIDE, $ControlGUI)
            GUISetState(@SW_HIDE, $ImageGUI)
    EndSwitch
EndFunc   ;==>ShowOrHideGUI

Func RunIt($WhichOne, $jumplistprog = "")
    Switch $jumplistprog
        Case ""
            Switch $WhichOne
                Case 11
                    Beep(1000, 50)
                    Beep(2000, 50)
                    Beep(500, 50)
                    Exit
                Case Else
                    $readjumplisted = IniRead($ini_file, "PL-Button_" & $WhichOne, 1, "")
                    If $readjumplisted <> "" And FileExists($readjumplisted) Then
                        If StringInStr($readjumplisted, ".au3") Then
                            Run(@ProgramFilesDir & "\AutoIt3\AutoIt3" & " " & '"' & $readjumplisted & '"')
                            ;ShellExecute ($readjumplisted)
                        Else
                            ShellExecute($readjumplisted)
                        EndIf
                    Else
                        MsgBox(64, "Playlet's Launcher", "Button " & $WhichOne, 3)
                    EndIf
            EndSwitch
        Case Else
            $readjumplisted = IniRead($ini_file, "PL-Button_" & $WhichOne, $jumplistprog, "")
            If $readjumplisted <> "" And FileExists($readjumplisted) Then
                If StringInStr($readjumplisted, ".au3") Then
                    Run(@ProgramFilesDir & "\AutoIt3\AutoIt3" & " " & '"' & $readjumplisted & '"')
                    ;ShellExecute ($readjumplisted)
                Else
                    ShellExecute($readjumplisted)
                EndIf
            Else
                MsgBox(64, "Playlet's Launcher", "Button " & $WhichOne, 3)
            EndIf
    EndSwitch
    Beep(1000, 50)
    Beep(2000, 50)
EndFunc   ;==>RunIt

Func HideJumplistGUI()
    GUISetState(@SW_HIDE, $JumplistTextGUI)
    GUISetState(@SW_HIDE, $JumplistMGUI)
    GUICtrlSetData($JumplistLabelArraytitle, "")
    GUICtrlSetImage($jump_icon, "")
    For $i = 1 To 15
        GUICtrlSetData($JumplistLabelArray[$i][0], "")
    Next
    WinMove($JumplistMGUI, "", $DesktopWidth, $DesktopHeight)
    WinMove($JumplistTextGUI, "", $DesktopWidth, $DesktopHeight)
EndFunc   ;==>HideJumplistGUI

Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam)
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $DropFilesArray[$i + 2]
        $DropFilesArray[$i + 1] = DllStructGetData($pFileName, 1)
        $pFileName = 0
    Next
    $DropFilesArray[0] = UBound($DropFilesArray) - 1
EndFunc   ;==>WM_DROPFILES_FUNC

Func GetNetStatus()
    Switch @IPAddress1
        Case "127.0.0.1"
            If $offline <> 1 Then
                GUICtrlSetData($textarray[11], "Offline")
                GUICtrlSetData($textarray[12], "Usage: -")
                $offline = 1
            EndIf
        Case Else
            If $offline <> 0 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)
                GUICtrlSetData($textarray[11], "Online (0')")
                GUICtrlSetData($textarray[12], "Usage: 0 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)
            $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
EndFunc   ;==>GetNetStatus

Func LoadNetChecking()
    Local Const $MAX_PATH = 260, $RAS_MaxDeviceType = 16, $RAS_MaxEntryName = 256, $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 Image_Draw($State = "normal", $Case = "")
    Local $Image[13]
    For $i = 1 To 11
        $Image[$i] = $Normal_Image
    Next
    $Image[12] = $Exit_Image_Normal
    Local $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($Width, $Height, $hGraphic1)
    Local $hGraphic2 = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    Switch $State
        Case "over"
            Switch $Case
                Case 1 To 10
                    $Image[$Case] = $Over_Image
                Case 11
                    $Image[12] = $Exit_Image_Over
            EndSwitch
        Case "pressed"
            Switch $Case
                Case 1 To 10
                    $Image[$Case] = $Pressed_Image
                Case 11
                    $Image[12] = $Exit_Image_Pressed
            EndSwitch
    EndSwitch
    For $i = 1 To 10
        _GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[$i], 0, ($i - 1) * 41, $Width, 57)
    Next
    _GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[11], 4, 410, 119, 57)
    _GDIPlus_GraphicsDrawImageRect($hGraphic2, $Image[12], 108, 410, 56, 57)
    _GDIPlus_GraphicsDispose($hGraphic2)
    _GDIPlus_GraphicsDispose($hGraphic1)
    Return $hBitmap
EndFunc   ;==>Image_Draw

Func Instructions()
    $text = "To:" & @CRLF
    $text &= " ____________________________________________________________________________________  " & @CRLF
    $text &= "  Launch files/folders                        - use left mouse button to launch first file from the button jumplist" & @CRLF
    $text &= "                                                          " & @CRLF
    $text &= "                                                            - use right mouse button to show button jumplist and then run file" & @CRLF
    $text &= " ____________________________________________________________________________________  " & @CRLF
    $text &= "  Add files/folders to buttons              - use drag-and-drop method" & @CRLF
    $text &= " ____________________________________________________________________________________  " & @CRLF
    $text &= "  Remove files/folders from buttons    - remove single item from jumplist by dragging it away from the" & @CRLF
    $text &= "                                                              jumplist and releasing it" & @CRLF
    $text &= "                                                          " & @CRLF
    $text &= "                                                            - remove all items from jumplist (all files on button) by dragging" & @CRLF
    $text &= "                                                              button away from the launcher and releasing it" & @CRLF
    $text &= " ____________________________________________________________________________________  " & @CRLF
    $text &= "  Check/sort files/folders                    - use tray menu to check if files that were added to the jumplist" & @CRLF
    $text &= "                                                              (button) still exist (if you move it somewhere after a while);" & @CRLF
    $text &= "                                                                also sorts files" & @CRLF
    $text &= " ____________________________________________________________________________________  " & @CRLF
    $text &= "  Change launcher position                  - drag it with both left and right mouse buttons pressed (use net" & @CRLF
    $text &= "                                                              status button for dragging - best result)" & @CRLF
    $text &= " ____________________________________________________________________________________  " & @CRLF
    $text &= "  Change to Pause Mode and back      - use tray menu" & @CRLF
    $text &= " ____________________________________________________________________________________  "
    MsgBox(64, "Playlet's Launcher", $text)
EndFunc   ;==>Instructions
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...