Jump to content

Recommended Posts

Posted (edited)

I have an old fullscreen game (really old) and it crashes alot. When it crashes all the icons on desktop are screwed up (moved)

how would I get the locatation of all icons on screen, so I could put them back?

One idea is useing pixel serches and then move them useing mousedown() and mouseup(), but thats unreliable. I need a more stable method of getting their locatations. Also, what if I had mutiple items with the same icon?

How would I get the positation (and name?) of all icons on desktop, and at the click of a button (useing a function), put them back where they were?

**EDIT**

i have found what i have been looking for:

#include <GuiListView.au3>

$inifile = "temp icon restore.ini"
WinActivate("Program Manager")
WinWaitActive("Program Manager")
$hWnd_LV = ControlGetHandle("[CLASS:Progman]","","SysListView321")

If Not FileExists($inifile) Then 
    _SaveIcons()
Else
    _SmartRestore()
EndIf

Func _SaveIcons()
    $chksum = 0
    FileClose(FileOpen($inifile,2))
    For $i = 0 to _GUICtrlListView_GetItemCount($hWnd_LV) - 1
        $iconposx = _GUICtrlListView_GetItemPositionX($hWnd_LV,$i)
        $iconposy = _GUICtrlListView_GetItemPositionY($hWnd_LV,$i)
        $iconname = _GUICtrlListView_GetItemText($hWnd_LV,$i)
        IniWriteSection($inifile,$iconname,"X=" & $iconposx & @LF & "Y=" & $iconposy)
        $chksum = $chksum + $iconposx
    Next
    IniWrite($inifile,"chksum","",$chksum);"chksum=" & $chksum)
EndFunc

Func _SmartRestore()
    $chksum2 = 0
    $new_chksum = 0
    $old_chksum = IniRead($inifile,"chksum","",65854674)
    For $i = 0 to _GUICtrlListView_GetItemCount($hWnd_LV) - 1
        $iconposx2 = _GUICtrlListView_GetItemPositionX($hWnd_LV,$i)
        $chksum2 = $chksum2 + $iconposx2
    Next
    $new_chksum = $chksum2
If $new_chksum = $old_chksum Then 
    Exit
Else
    _RestoreIcons()
EndIf
EndFunc
    
Func _RestoreIcons()
    For $i = 0 To _GUICtrlListView_GetItemCount($hWnd_LV) - 1
        $iconpos = IniReadSection($inifile,_GUICtrlListView_GetItemText($hWnd_LV,$i))
        If IsArray($iconpos) Then 
            $iconposx = _GUICtrlListView_GetItemPositionX($hWnd_LV,$i)
            $iconposy = _GUICtrlListView_GetItemPositionY($hWnd_LV,$i)
            If $iconposx <> $iconpos[1][1] Or $iconposy <> $iconpos[2][1] Then _GUICtrlListView_SetItemPosition($hWnd_LV, $i, $iconpos[1][1], $iconpos[2][1])
        EndIf
        $iconpos = 0    
    Next
EndFunc

please note that _restoreicons just restores the icon positations

_smartrestore checks if anything changed

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Posted

Search for "Desktop Icons Restorator" in the examples forum.

my antivirus ate the program, and it seems to be written in an older version of autoit ( autoit 2 maby? )

i would need help rewriteing it to use it, might be easyer to start from scratch

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Posted

The desktop is just a listview so you can use the regular _GUICtrlListview_* UDF's :D

Example here.

i saw your script. made me lol. any way to speed it up? it was AWESOME!

that thread gave me what i needed. ty

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Posted

i saw your script. made me lol. any way to speed it up? it was AWESOME!

that thread gave me what i needed. ty

Test _GUICtrlListView_Begin/EndUpdate. Should speed it up a little.

Also use less icons, will speed it up a lot. Increasing the values on line 10 and 11 is also a good idea :D

Broken link? PM me and I'll send you the file!

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
×
×
  • Create New...