corgano Posted April 6, 2009 Share Posted April 6, 2009 (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: expandcollapse popup#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 April 7, 2009 by corgano 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Authenticity Posted April 6, 2009 Share Posted April 6, 2009 Hmm.. strange. What about backing-up the desktop directory? Link to comment Share on other sites More sharing options...
KaFu Posted April 6, 2009 Share Posted April 6, 2009 Search for "Desktop Icons Restorator" in the examples forum. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
corgano Posted April 6, 2009 Author Share Posted April 6, 2009 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 Link to comment Share on other sites More sharing options...
monoceres Posted April 6, 2009 Share Posted April 6, 2009 The desktop is just a listview so you can use the regular _GUICtrlListview_* UDF's Example here. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
corgano Posted April 6, 2009 Author Share Posted April 6, 2009 The desktop is just a listview so you can use the regular _GUICtrlListview_* UDF's 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 Link to comment Share on other sites More sharing options...
monoceres Posted April 6, 2009 Share Posted April 6, 2009 i saw your script. made me lol. any way to speed it up? it was AWESOME!that thread gave me what i needed. tyTest _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 Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now