I'm rebuilding the most useless and annoying tool ever, the "Desktop Cleanup Wizard" from XP, it mostly works but I'm having trouble with showing icons in GUI 3.
In lines 75 through 85, I'm trying to get the icons attached to each listview line but I keep getting the wrong ones. I've hammered on this for hours now and I believe I don't quite understand what the problem is.
Here is the code, btw it makes a .txt list of "checked" entries from GUI 2, then parses that .txt list to add the icons into Gui 3's listview, probably wrong.
Code: Select all
#SingleInstance, force
;Menu, Tray, Icon, %A_ScriptDir%\info.ico
Gui, 1: New
Gui, 1: Add, Picture, x0 y0 w164 h314, Bitmap200.bmp
Gui, 1: Add, Picture, x164 y0 w351 h314, whitebkg.jpg
Gui, Font, s13, Verdana
Gui, 1: Add, Text, x170 y10 w500 h50 +BackgroundTrans, Welcome to the Desktop Cleanup`nWizard
Gui, Font
Gui, 1: Add, Text, x170 y70 w500 h50 +BackgroundTrans, This wizard helps you clean up your desktop by moving`nunused shortcuts to a desktop folder called Unused`nDesktop Shortcuts.
Gui, 1: Add, Text, x170 y126 w500 h50 +BackgroundTrans, The wizard does not move, change or delete any of your`nprograms. If you later decide that you want a shortcut back`non your desktop, you can restore it from the Unused`nDesktop Shortcuts folder.
Gui, 1: Add, Text, x170 y280 w500 h50 +BackgroundTrans, To continue, click Next.
Gui, 1: Add, Button, x253 y326 w75 h23 +Disabled, `< Back
Gui, 1: Add, Button, x329 y326 w75 h23 vNext gCheckDesktop, Next `>
Gui, 1: Add, Button, x415 y326 w75 h23 vCancel gCancel, Cancel
Gui, 1: Show, w500 h360, Desktop Cleanup Wizard
return
CheckDesktop:
Gui, 1: Hide
Gui, 2: New
Gui, 2: Add, Text, w500 h30, The shortcuts selected below will be moved to Unused Desktop Shortcuts bla bla bla...
Gui, 2: Add, ListView, x40 y130 h146 w380 Checked +ReadOnly +Sort vList1, Shortcut to Clean Up |Date Last Used
Gui, 2: Add, Button, x253 y326 w75 h23 gBackTo1, `< Back
Gui, 2: Add, Button, x329 y326 w75 h23 vNext gConfirmShortcuts, Next `>
Gui, 2: Add, Button, x415 y326 w75 h23 vCancel gCancel, Cancel
Loop, %A_Desktop%\*.lnk
{
FileGetShortcut, %A_LoopFileFullPath%, ShortcutTarget
SplitPath, A_LoopFileFullPath,,,, OutNameNoExt
if !FileExist(ShortcutTarget)
{
LV_Add("Check", OutNameNoExt, "No Target")
continue
}
FileGetTime, DateCreatedTimeRaw, %A_LoopFileFullPath%, C
FileGetTime, LastAccessedTimeRaw, %A_LoopFileFullPath%, A
if (DateCreatedTimeRaw <= LastAccessedTimeRaw)
Checkbox = "Check"
else
Checkbox = ""
FormatTime, LastAccessedTimeFormatted, %LastAccessedTimeRaw%, M`/dd`/yyyy
LV_Add(Checkbox, OutNameNoExt, LastAccessedTimeFormatted)
}
Gui, 2: Show, w500 h360, Desktop Cleanup Wizard
return
ConfirmShortcuts:
FileDelete, %A_Temp%\temp.txt
ShortcutNames := ""
Row := 0
Loop
{
Row := LV_GetNext(Row, "C") ; finds checked checkboxes
if (!Row)
break
LV_GetText(Name, Row, 1)
FileAppend, %Name%`,, %A_Temp%\temp.txt
}
Gui, 2: Hide
Gui, 3: New
Gui, 3: Add, Picture, x0 y0 w164 h314, Bitmap200.bmp
Gui, 3: Add, Picture, x164 y0 w351 h314, whitebkg.jpg
Gui, 3: Font, s13, Verdana
Gui, 3: Add, Text, x170 y10 w500 h50 +BackgroundTrans, Completing the Desktop Cleanup`nWizard
Gui, 3: Font
Gui, 3: Add, Text, x170 y70 w500 h50 +BackgroundTrans, Windows will move the following (number of checked items) bla bla
Gui, 3: Add, ListView, x173 y122 h116 w286 -Hdr +ReadOnly vList2, HiddenColumnName
; This is where I'm having trouble, associating the icons which "FileGetShortcut" gets, the wrong icons are shown
ImageListID := IL_Create()
LV_SetImageList(ImageListID)
FileRead, ShortcutsToMove, %A_Temp%\temp.txt
Loop, Parse, ShortcutsToMove, `,
{
If A_Loopfield =
break
FileGetShortcut, %A_Desktop%\%A_LoopField%.lnk, ShortcutTarget
IL_Add(ImageListID, ShortcutTarget)
LV_Add("Icon" . A_Index, A_LoopField)
}
Gui, 3: Add, Button, x253 y326 w75 h23 gBackTo2, `< Back
Gui, 3: Add, Button, x329 y326 w75 h23 vNext gMoveUnusedShortcuts, Finish
Gui, 3: Add, Button, x415 y326 w75 h23 vCancel gCancel, Cancel
Gui, 3: Show, w500 h360, Desktop Cleanup Wizard
return
MoveUnusedShortcuts:
If !FileExist(A_Desktop "\Unused Desktop Shortcuts")
FileCreateDir, %A_Desktop%\Unused Desktop Shortcuts
Loop, Parse, ShortcutsToMove, `,
{
If A_Loopfield =
break
;FileMove, %A_Desktop%\%A_LoopField%.lnk, %A_Desktop%\Unused Desktop Shortcuts
MsgBox, Shortcuts not moved, testing
}
ExitApp
BackTo1:
Gui, 2: Hide
Gui, 1: Show
return
BackTo2:
Gui, 3: Hide
Gui, 2: Show
return
Esc::
GuiClose:
Cancel:
FileDelete, %A_Temp%\temp.txt
ExitApp