I wrote this script in the past few days. School is finishing and I hardly got some homework recently, so I had plenty of time to work on something I needed and to make it at least nice-looking
WHat is doeas is create an icon on you desktop that, when hovered, grows and shows all the icons you decided to put in the "box"
To delete items just press the X on the top part of the window so it will become X. This means you are in "Delete Mode" so instead of executing whatever you click, the script deletes it from the box
Just click it back again to switch off the "Delete Mode"
The + on the top of the window, lets you add icons to the "box"
I hope you like it
Comments are welcome
here is the script:
#include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <StaticConstants.au3> #include <Array.au3> #include <Misc.au3> #NoTrayIcon Global $Width, $Icon_Handles[1], $Label_Handles[1], $Maxed = False, $DelMode = False, $t = 0 Global $Win, $IniPath = @TempDir & "\DeskBox.ini" Global $IconSize = 32 $Icons = _GetAllInfo() $Gui_X = IniRead($IniPath, "Settings", "X", 50) $Gui_Y = IniRead($IniPath, "Settings", "Y", 50) $AutoRun = IniRead($IniPath, "Settings", "AutoRun", 1) If $AutoRun = 1 Then RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "DeskBox", "REG_SZ", @ScriptFullPath) Else RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "DeskBox") EndIf $Gui = GUICreate("", 60, 60, $Gui_X, $Gui_Y, $WS_POPUP, $WS_EX_TOOLWINDOW, WinGetHandle("[CLASS:Progman]")) GUISetBkColor(0x404040) WinSetTrans($Gui, "", 220) _GuiRoundCorners($Gui, 0, 0, 4, 4) $Title = GUICtrlCreateLabel("DeskBox", 0, 46, 60, 14, $SS_CENTER) GUICtrlSetBkColor(-1, 0x202020) GUICtrlSetResizing($Title, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT) GUICtrlSetColor($Title, 0xCCCCCC) $Bar = GUICtrlCreateLabel("", 0, 0, 60, 16) GUICtrlSetResizing($Bar, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT) GUICtrlSetBkColor($Bar, 0xbbFF00) $Add = GUICtrlCreateLabel("+", 45, 0, 15, 14, $SS_CENTER) GUICtrlSetResizing($Add, $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT + $GUI_DOCKWIDTH) GUICtrlSetBkColor($Add, 0xbbFF00) GUICtrlSetTip($Add, "Add Element") $Del = GUICtrlCreateLabel("x", 30, 0, 15, 14, $SS_CENTER) GUICtrlSetResizing($Del, $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT + $GUI_DOCKWIDTH) GUICtrlSetBkColor($Del, 0xbbFF00) GUICtrlSetTip($Del, "Delete Element") $Info = GUICtrlCreateLabel("i", 15, 0, 15, 14, $SS_CENTER) GUICtrlSetResizing($Info, $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT + $GUI_DOCKWIDTH) GUICtrlSetBkColor($Info, 0xbbFF00) GUICtrlSetTip($Info, "Info") ControlDisable($Gui, "", $Bar) GUISetState() While 1 If $t > 2000 Then GUICtrlSetData($Title, "DeskBox") $t = "" EndIf $msg = GUIGetMsg() For $i = 1 To UBound($Icon_Handles) - 1 If $msg = $Icon_Handles[$i] Or $msg = $Label_Handles[$i] Then _Execute($Icons[$i]) EndIf Next Switch $msg Case $Add $Open = FileOpenDialog("Chose File", @DesktopDir, "all files (*.*)") If Not @error Then If StringInStr($Open, "]") Or StringInStr($Open, "[") Then TrayTip("Error!", "Please remove any ''['' or '']'' chars from the file's name you want to add", 10, 16) Else IniWrite($IniPath, $Open, "filename", $Open) EndIf EndIf $Icons = _GetAllInfo() $Maxed = False Case $Del If $DelMode = False Then GUICtrlSetColor($Del, 0xFF0000) GUICtrlSetTip($Del, "Delete Mode ON") $DelMode = True Else GUICtrlSetColor($Del, 0x000000) GUICtrlSetTip($Del, "Delete Mode OFF") $DelMode = False EndIf Case $Info GUICtrlSetData($Title, "CopyLeft 2009 torels_") $t = TimerInit() EndSwitch If _IsPressed("01") Then _WindowDrag() $Win = WinGetPos($Gui) If (MouseGetPos(0) > $Win[0] + $Win[2] + 10 Or MouseGetPos(0) < $Win[0] - 10) Then ;out X Min() ContinueLoop EndIf If (MouseGetPos(1) > $Win[1] + $Win[3] - 15 Or MouseGetPos(1) < $Win[1] - 10) Then ;out Y Min() ContinueLoop EndIf If (MouseGetPos(0) > $Win[0] And MouseGetPos(0) < $Win[0] + $Win[2]) Then ;in X If $Maxed = False Then Max($Win, $Width) ContinueLoop EndIf If (MouseGetPos(1) > $Win[1] And MouseGetPos(1) < $Win[1] + $Win[3]) Then ;in Y If $Maxed = False Then Max($Win, $Width) ContinueLoop EndIf WEnd Func Max($aWin, $Size) ControlShow($Gui, "", $Add) ControlShow($Gui, "", $Bar) ControlShow($Gui, "", $Del) ControlShow($Gui, "", $Info) For $i = $aWin[2] To $Size Step 10 WinMove($Gui, "", $aWin[0], $aWin[1], $aWin[2] + $i, $aWin[2] + $i + 15 * $Width / $IconSize) _GuiRoundCorners($Gui, 0, 0, 4, 4) Next For $i = 1 To UBound($Icon_Handles) - 1 GUICtrlDelete($Icon_Handles[$i]) Next For $i = 1 To UBound($Label_Handles) - 1 GUICtrlDelete($Label_Handles[$i]) Next $i = 1 $string = "" ReDim $Icon_Handles[1] For $y = 0 To $Width / $IconSize For $x = 0 To $Width / $IconSize If StringRight($Icons[$i], 4) = ".exe" Or StringRight($Icons[$i], 4) = ".lnk" Or StringRight($Icons[$i], 4) = ".ani" Then $Icon = GUICtrlCreateIcon($Icons[$i], -1, $x * $IconSize + 5 * $x, $y * $IconSize + 17 + 20 * $y, $IconSize, $IconSize) _ArrayAdd($Icon_Handles, $Icon) GUICtrlSetTip($Icon, $Icons[$i]) $l = GUICtrlCreateLabel(_GetFileName($Icons[$i]), $x * $IconSize + 5 * $x, $y * $IconSize + 17 + 20 * $y + $IconSize, $IconSize, 15) GUICtrlSetColor(-1, 0xEEEEEE) GUICtrlSetTip($l, $Icons[$i]) _ArrayAdd($Label_Handles, $l) ElseIf FileGetAttrib($Icons[$i]) = "D" Then $Icon = GUICtrlCreateIcon("shell32.dll", -5, $x * $IconSize + 5 * $x, $y * $IconSize + 17 + 20 * $y, $IconSize, $IconSize) _ArrayAdd($Icon_Handles, $Icon) GUICtrlSetTip($Icon, $Icons[$i]) $l = GUICtrlCreateLabel(_GetFileName($Icons[$i]), $x * $IconSize + 5 * $x, $y * $IconSize + 17 + 20 * $y + $IconSize, $IconSize, 15) GUICtrlSetColor(-1, 0xEEEEEE) GUICtrlSetTip($l, $Icons[$i]) _ArrayAdd($Label_Handles, $l) Else $Icon = GUICtrlCreateIcon(_GetIcon($Icons[$i]), -1, $x * $IconSize + 5 * $x, $y * $IconSize + 17 + 20 * $y, $IconSize, $IconSize) _ArrayAdd($Icon_Handles, $Icon) GUICtrlSetTip($Icon, $Icons[$i]) $l = GUICtrlCreateLabel(_GetFileName($Icons[$i]), $x * $IconSize + 5 * $x, $y * $IconSize + 17 + 20 * $y + $IconSize, $IconSize, 15) GUICtrlSetColor(-1, 0xEEEEEE) GUICtrlSetTip($l, $Icons[$i]) _ArrayAdd($Label_Handles, $l) EndIf $i += 1 If $i > UBound($Icons)-1 Then ExitLoop Next If $i > UBound($Icons)-1 Then ExitLoop Next $Maxed = True $Win = WinGetPos($Gui) EndFunc ;==>Max Func Min() If $Maxed = True Then ControlHide($Gui, "", $Add) ControlHide($Gui, "", $Bar) ControlHide($Gui, "", $Del) ControlHide($Gui, "", $Info) For $i = 1 To UBound($Icon_Handles) - 1 GUICtrlDelete($Icon_Handles[$i]) Next For $i = 1 To UBound($Label_Handles) - 1 GUICtrlDelete($Label_Handles[$i]) Next WinMove($Gui, "", $Win[0], $Win[1], 60, 60) _GuiRoundCorners($Gui, 0, 0, 4, 4) $Maxed = False EndIf EndFunc ;==>Min Func _Execute($sFileName) If $DelMode = True Then If UBound($Icons)>2 Then IniDelete($IniPath, $sFileName) $Icons = _GetAllInfo() $Maxed = False Else MsgBox(0,"Error","Atleast One file must be in the box!") $Icons = _GetAllInfo() $Maxed = False EndIf Else ShellExecute($sFileName) EndIf EndFunc ;==>_Execute Func _GetFileName($sFile) Local $sRet = "", $i = 1 Do $i += 1 Until StringLeft(StringRight($sFile, $i), 1) = "\" $sFile = StringMid($sFile, StringLen($sFile) - $i + 2, $i) If Not FileGetAttrib($sFile) = "D" Then ;Not a Directory $i = 1 Do $i += 1 Until StringRight(StringLeft($sFile, $i), 1) = "." $sFile = StringMid($sFile, 1, $i - 1) EndIf Return $sFile EndFunc ;==>_GetFileName Func _WindowDrag() While _IsPressed("01") DllCall("user32.dll", "int", "SendMessage", "hWnd", $Gui, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0) $Win = WinGetPos($Gui) IniWrite($IniPath, "Settings", "X", $Win[0]) IniWrite($IniPath, "Settings", "Y", $Win[1]) WEnd EndFunc ;==>_WindowDrag Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3) Dim $pos, $ret, $ret2 $pos = WinGetPos($h_win) $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3) If $ret[0] Then $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1) If $ret2[0] Then Return 1 Else Return 0 EndIf Else Return 0 EndIf EndFunc ;==>_GuiRoundCorners Func _GetAllInfo() $sections = IniReadSectionNames($IniPath) $W=0 If Not IsArray($sections) Then $Open = FileOpenDialog("Chose File", @DesktopDir, "all files (*.*)") If Not @error Then If StringInStr($Open, "]") Or StringInStr($Open, "[") Then MsgBox(0,"Error!", "Please remove any ''['' or '']'' chars from the file's name you want to add") Return Else IniWrite($IniPath, $Open, "filename", $Open) $sections = IniReadSectionNames($IniPath) $W=1 EndIf EndIf EndIf $Width = $IconSize * Ceiling(Sqrt($sections[0]+$W)) Dim $aRet[1] For $i = 1 To $sections[0] If $sections[$i] <> "Settings" Then _ArrayAdd($aRet, IniRead($IniPath, $sections[$i], "filename", "")) Next Return $aRet EndFunc ;==>_GetAllInfo Func _GetIcon($file, $ReturnType = 0) $FileType = StringSplit($file, ".") $FileType = $FileType[UBound($FileType) - 1] $FileParam = RegRead("HKEY_CLASSES_ROOT\." & $FileType, "") $DefaultIcon = RegRead("HKEY_CLASSES_ROOT\" & $FileParam & "\DefaultIcon", "") If Not @error Then $IconSplit = StringSplit($DefaultIcon, ",") ReDim $IconSplit[3] $Iconfile = $IconSplit[1] $IconID = $IconSplit[2] Else $Iconfile = @SystemDir & "\shell32.dll" $IconID = -219 EndIf If $ReturnType = 0 Then Return $Iconfile Else Return $IconID EndIf EndFunc ;==>_GetIcon
EDIT: Now It's Working!
Edited by torels, 11 June 2009 - 07:50 PM.









