Moderators Melba23 Posted January 14, 2010 Moderators Share Posted January 14, 2010 (edited) NEW 2.1 VERSION: Uploaded 15 Jan 10Hi,KaFu and I found we were working on very similar ideas to restore the Desktop icons to their normal place if they became "rearranged". Vista seems to like this doing on occasion just for fun - but we all know some apps and games which change the display resolution or move icons around. This annoys "tidy" people who like their desktops arranged "just so" - I am particularly thinking of this desktop when I say that! We combined efforts and here is the result of our labours (script and icon):Operation is easy - press "Save" to store a particular configuration and "Restore" to reset the icons to the saved positions in the selected configuration file. "Delete" allows you to remove unwanted configuration files from the list. Thanks to KaFu there is a commandline option so that the restoration can be run via HotKeys if required (that is why the script warns that it should be compiled for full functionality). You can decide what to do with any icons that have been added since you last saved the configuration file - the default is to put them in the top-left cormer, but you can also banish them way off-screen or, more sensibly, specify a location for them.We hope you find it useful. As usual, comments and suggstions are most welcome.M23 & KaFuEdit: New 2.1 version uploaded 15 Jan 10 Edited January 15, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
UEZ Posted January 14, 2010 Share Posted January 14, 2010 2 things I want to mention:display for screen resolution for multi monitor is not working properly, only main screen resolution will be displayedrestore did not work properly because after sorting desktop icons e.g. by size and restore it the position of the icons were not set as beforeRegards,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
KaFu Posted January 14, 2010 Share Posted January 14, 2010 (edited) @UEZ:Could you please test this?expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Desktop.ico #AutoIt3Wrapper_outfile=ICU.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Description=Icon Configuration Utility #AutoIt3Wrapper_Res_Fileversion=2.0.0.0 #AutoIt3Wrapper_Res_LegalCopyright=Melba23 2009-2010, KaFu 2010 ://////=__= #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ; ##### Icon Configuration Utility ##### ; ; Script Version: 2.0 ; As at 13 Jan 10 ; #Region ;----- Includes ----- #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <ComboConstants.au3> #include <GuiListView.au3> #include <Date.au3> #include <File.au3> #include <WinAPI.au3> #EndRegion ;----- Includes ----- #Region ;----- Declarations ----- If Not @Compiled Then MsgBox(64, "ICU Info", "ICU needs to be compiled for full functionality") If @OSArch = "X64" And @AutoItX64 = 0 Then MsgBox(16, "ICU Error", "This version of ICU is 32-bit compiled" & @CRLF & _ "and will not run correctly with a 64-bit OS" & @CRLF & @CRLF & _ "Please recompile as a 64-bit executable") Exit EndIf Global $sConfig_Name, $sConfig_Path, $hList_Start Global $hDesktop = _WinAPI_GetDesktopWindow() Global $tRcDesktop, $DesktopWidth, $DesktopHeight ; Match only exact window titles Global $iOldOpt = Opt("WinTitleMatchMode", 3) ; Set Desktop path Global $sDesktop_Path = @DesktopDir ; See if app is in Program Files If @ScriptDir = @ProgramFilesDir Then ; If app in Program Files need to save config files elsewhere If Not FileExists(@AppDataDir & "\ICF") Then DirCreate(@AppDataDir & "\ICF") $sConfig_Path = @AppDataDir & "\ICF" Else ; Can use working directory $sConfig_Path = @ScriptDir EndIf ; Get list of existing config files Global $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) #EndRegion ;----- Declarations ----- #Region ;----- Create GUI ----- Global $sGUITitle = "Icon Configuration Utility - 64bit version" If @OSArch = "X86" Then $sGUITitle = "Icon Configuration Utility - 32bit version" Global $hMain_GUI = GUICreate($sGUITitle, 370, 247) GUISetBkColor(0xFFFFFF) Global $hSave_Button = GUICtrlCreateButton("Save", 10, 175, 80, 25) Global $hRestore_Button = GUICtrlCreateButton("Restore", 100, 175, 80, 25) Global $hDelete_Button = GUICtrlCreateButton("Delete", 190, 175, 80, 25) Global $hAbout_Button = GUICtrlCreateButton("About", 280, 175, 80, 25) GUICtrlCreateLabel("List of icon configuration files (*.icf)", 10, 8, 200, 20) Global $hState_Label = GUICtrlCreateLabel("Ready", 280, 7, 80, 16, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xCCFFCC) GUICtrlCreateLabel("Command line restore via", 10, 210, 120, 13) GUICtrlSetFont(-1, 7, 400, 0, "Lucida Console") GUICtrlCreateLabel("icu.exe restore #", 10, 225, 120, 13) GUICtrlSetFont(-1, 7, 400, 0, "Lucida Console") GUICtrlCreateLabel("Move unknown icons", 152, 214, 110, 13) Global $cID_Combo_Unknown_Icon = GUICtrlCreateCombo("to position 0,0", 260, 210, 100, 20, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "off-screen|ask per icon") Global $hFile_List = GUICtrlCreateListView("#|Name|Date|Resolution", 10, 30, 350, 135, $LVS_SINGLESEL, $LVS_EX_FULLROWSELECT) ; Set up alt line colouring GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) ; Set col width _GUICtrlListView_SetColumnWidth(-1, 0, 20) _GUICtrlListView_SetColumnWidth(-1, 1, 117) _GUICtrlListView_SetColumnWidth(-1, 2, 145) _GUICtrlListView_SetColumnWidth(-1, 3, $LVSCW_AUTOSIZE_USEHEADER) If IsArray($aConfig_List) Then _Fill_ListView() Else GUICtrlCreateListViewItem("|No Files Found", $hFile_List) GUICtrlSetState($hRestore_Button, $GUI_DISABLE) EndIf #Region ; ----- Command line ----- If $CmdLine[0] = 2 And StringLower($CmdLine[1]) = "restore" Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[Number($CmdLine[2])] If FileExists($sConfig_Name) Then _Set_Locations_Desktop() Exit EndIf #EndRegion ; ----- Command line ----- GUISetState() #EndRegion ;----- Create GUI ----- #Region ;----- Main loop ----- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Opt("WinTitleMatchMode", $iOldOpt) Exit Case $hSave_Button _Save_Config() Case $hRestore_Button _Restore_Config() Case $hDelete_Button Global $iIndex = _GUICtrlListView_GetSelectedIndices($hFile_List, True) If $iIndex[0] = 1 Then If MsgBox(4 + 16, $sGUITitle, "Are you sure you want to delete """ & _GUICtrlListView_GetItemText($hFile_List, $iIndex[1], 1) & """") = 6 Then _Delete_Config() EndIf Case $hAbout_Button _On_Info() EndSwitch WEnd #EndRegion ;----- Main loop ----- ; Functions #Region ;----- Save ----- Func _Save_Config() Local $sConfig_Type = InputBox($sGUITitle, "Enter a name for the new icon configuration file:", Default, Default, 300, 130) If @error Then Return GUICtrlSetData($hState_Label, "Working") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get new config filename If IsArray($aConfig_List) Then Local $iNew_Index = $aConfig_List[0] + 1 $sConfig_Name = $sConfig_Path & "\IconConfigFile" & StringFormat("%03i", $iNew_Index) & ".icf" Else $sConfig_Name = $sConfig_Path & "\IconConfigFile001.icf" EndIf ; Write config file data IniWrite($sConfig_Name, "Data", "Type", $sConfig_Type) IniWrite($sConfig_Name, "Data", "Date", _NowCalc()) $tRcDesktop = _WinAPI_GetWindowRect($hDesktop) $DesktopWidth = DllStructGetData($tRcDesktop, 3) $DesktopHeight = DllStructGetData($tRcDesktop, 4) IniWrite($sConfig_Name, "Data", "Resolution", $DesktopWidth & "x" & $DesktopHeight) IniWrite($sConfig_Name, "Data", "Unknown_Icon_Handling", GUICtrlRead($cID_Combo_Unknown_Icon)) ; Save Desktop locations _Save_Locations_Desktop() ; Refill list _Fill_ListView() ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) GUICtrlSetState($hRestore_Button, $GUI_ENABLE) EndFunc ;==>_Save_Config ; ------------ Func _Save_Locations_Desktop() Local $hExplorer_List = ControlGetHandle("Program Manager", "", "SysListView321") ; Loop through folder contents For $i = 0 To _GUICtrlListView_GetItemCount($hExplorer_List) - 1 ; Get name Local $sKey_Name = _GUICtrlListView_GetItemText($hExplorer_List, $i) ; Get position Local $aPos = _GUICtrlListView_GetItemPosition($hExplorer_List, $i) Local $sValue_Pos = $aPos[0] & ":" & $aPos[1] ; Write to config file IniWrite($sConfig_Name, "Desktop", $sKey_Name, $sValue_Pos) Next EndFunc ;==>_Save_Locations_Desktop #EndRegion ;----- Save ----- #Region ;----- Restore ----- Func _Restore_Config() GUICtrlSetData($hState_Label, "Working") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get config file name Local $iIndex = GUICtrlRead($hFile_List) - $hList_Start If $iIndex > 0 Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[$iIndex] ; Restore Desktop _Set_Locations_Desktop() Else MsgBox(0, "Error", "No Configuration File Selected") EndIf ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) EndFunc ;==>_Restore_Config ; -------- Func _Set_Locations_Desktop() Local $hExplorer_List = ControlGetHandle("Program Manager", "", "SysListView321") GUICtrlSetData($cID_Combo_Unknown_Icon, IniRead($sConfig_Name, "Data", "Unknown_Icon_Handling", "to position 0,0")) ; Move all icons out of the viewable area to guarantee clear space for relocation $tRcDesktop = _WinAPI_GetWindowRect($hDesktop) $DesktopWidth = DllStructGetData($tRcDesktop, 3) $DesktopHeight = DllStructGetData($tRcDesktop, 4) For $i = 0 To _GUICtrlListView_GetItemCount($hExplorer_List) - 1 _GUICtrlListView_SetItemPosition($hExplorer_List, $i, $DesktopWidth, $DesktopHeight + 100 * $i) Next ; Now replace icons back in stored positions For $i = 0 To _GUICtrlListView_GetItemCount($hExplorer_List) - 1 ; Get name & position Local $sIcon_Name = _GUICtrlListView_GetItemText($hExplorer_List, $i) Local $sPos_Saved = IniRead($sConfig_Name, "Desktop", $sIcon_Name, "") If $sPos_Saved <> "" Then Local $aPos = StringSplit($sPos_Saved, ":") _GUICtrlListView_SetItemPosition($hExplorer_List, $i, $aPos[1], $aPos[2]) Else Switch GUICtrlRead($cID_Combo_Unknown_Icon) Case "off-screen" _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 9999, 9999) Case "ask per icon" Local $sAskAnswer = InputBox($sGUITitle, "Enter a position x,y", Default, Default, 300, 130) If @error Or Not StringInStr($sAskAnswer, ",") Then _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) Else Local $aAskAnswer = StringSplit($sAskAnswer, ",") If $aAskAnswer[0] = 2 Then _GUICtrlListView_SetItemPosition($hExplorer_List, $i, Number($aAskAnswer[1]), Number($aAskAnswer[2])) Else _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) EndIf EndIf Case Else _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) EndSwitch EndIf Next EndFunc ;==>_Set_Locations_Desktop #EndRegion ;----- Restore ----- #Region ;----- Delete ----- Func _Delete_Config() GUICtrlSetData($hState_Label, "Deleting") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get config file name Local $iIndex = GUICtrlRead($hFile_List) - $hList_Start If $iIndex > 0 Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[$iIndex] ; Delete config file FileRecycle($sConfig_Name) ; Renumber remaining config files $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) If IsArray($aConfig_List) Then For $i = 1 To $aConfig_List[0] Local $sSource = $sConfig_Path & "\" & $aConfig_List[$i] Local $sDest = $sConfig_Path & "\IconConfigFile" & StringFormat("%03i", $i) & ".icf" FileMove($sSource, $sDest) Next EndIf EndIf ; Refill list _Fill_ListView() ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) EndFunc ;==>_Delete_Config #EndRegion ;----- Delete ----- #Region ;----- Misc ----- Func _Fill_ListView() _GUICtrlListView_DeleteAllItems($hFile_List) ; Get list of files $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) ; Fill Listview If Not IsArray($aConfig_List) Then GUICtrlCreateListViewItem("|No Files Found", $hFile_List) GUICtrlSetState($hRestore_Button, $GUI_DISABLE) Return EndIf $hList_Start = GUICtrlCreateDummy() ; Start of list handles ; If > 9 files reduce final col size to leave place for v-scroll so no h-scroll If $aConfig_List[0] > 9 Then _GUICtrlListView_SetColumnWidth($hFile_List, 2, 95) ; Get data from files For $i = 1 To $aConfig_List[0] Local $sType = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Type", "Unknown") Local $sDate = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Date", "Unknown") Local $sRes = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Resolution", "Unknown") GUICtrlCreateListViewItem($i & "|" & $sType & "|" & $sDate & "|" & $sRes, $hFile_List) GUICtrlSetBkColor(-1, 0xCCFFCC) Next EndFunc ;==>_Fill_ListView #EndRegion ;----- Misc ----- #Region ;----- Info Functions ----- Func _On_Info() ;Show info messagebox MsgBox(4160, "About", "Icon Configuration Utility v2.0" & @CRLF & @CRLF & "Melba23 2009-2010, KaFu 2010") EndFunc ;==>_On_Info #EndRegion ;----- Info Functions -----Edit: And as far as I can see, all out-arranging options of desktop icons need to be switched off of course. Edited January 14, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
UEZ Posted January 14, 2010 Share Posted January 14, 2010 Ok, seems to be problem with "Align to Grid" option when it is selected (I assume standardly selected)! But anyway it should also work with that feature enabled! I tested it on Vista x32 (#AutoIt3Wrapper_UseX64=y was set in your code - have to remove it ;-)) Regards, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 14, 2010 Author Moderators Share Posted January 14, 2010 UEZ,It works perfectly for me on Vista x32 with the "Align to grid" selected. M23P.S. KaFu keeps adding that x64 line - you have no idea how many times I have deleted it! Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
KaFu Posted January 14, 2010 Share Posted January 14, 2010 It works perfectly for me on Vista x32 with the "Align to grid" selected. Maybe the reason was the usage of @DesktopHeight and @DesktopWidth macros in a multi-monitor setup? I replaced them by _WinAPI_GetDesktopWindow() + _WinAPI_GetWindowRect() calls in my example above.@UEZ: Did just the second version work, or also the initial version with snap-to-grid/auto-align disabled? @Melba: Works fine on Win7 with snap-to-grid enabled too.P.S. KaFu keeps adding that x64 line - you have no idea how many times I have deleted it! Now you know why I insisted on the line "If @OSArch = "X64" And @AutoItX64 = 0 Then" . For info, this script MUST be complied aligned to @OSArch, otherwise the _GUICtrlListView_GetItemPosition() function can't access the desktop window (listview limitation). OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Michel Claveau Posted January 14, 2010 Share Posted January 14, 2010 Hi !problem with "Align to Grid" selected+1(Test on: Win-7-32 ; the 4:50 PM Kafu's release)No problem with "Align to Grid" unselected Link to comment Share on other sites More sharing options...
UEZ Posted January 14, 2010 Share Posted January 14, 2010 It seems to be a problem with the "Move all icons out of the viewable area to guarantee clear space for relocation" routine! Further if you run "Now replace icons back in stored positions" twice it will place the icons properly!And I also added to get real monitor size (should support multi monitor size)!expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Desktop.ico #AutoIt3Wrapper_Outfile=ICU.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Description=Icon Configuration Utility #AutoIt3Wrapper_Res_Fileversion=2.0.0.0 #AutoIt3Wrapper_Res_LegalCopyright=Melba23 2009-2010, KaFu 2010 ://////=__= #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ; ##### Icon Configuration Utility ##### ; ; Script Version: 2.0 ; As at 13 Jan 10 ; #Region ;----- Includes ----- #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <ComboConstants.au3> #include <GuiListView.au3> #include <Date.au3> #include <File.au3> #EndRegion ;----- Includes ----- #Region ;----- Declarations ----- If Not @Compiled Then MsgBox(64, "ICU Info", "ICU needs to be compiled for full functionality") If @OSArch = "X64" And @AutoItX64 = 0 Then MsgBox(16, "ICU Error", "This version of ICU is 32-bit compiled" & @CRLF & _ "and will not run correctly with a 64-bit OS" & @CRLF & @CRLF & _ "Please recompile as a 64-bit executable") Exit EndIf Global $sConfig_Name, $sConfig_Path, $hList_Start Global $hScreen = WinGetHandle("Program Manager") Global $aScreen_Res = WinGetPos($hScreen) ; Match only exact window titles Global $iOldOpt = Opt("WinTitleMatchMode", 3) ; Set Desktop path Global $sDesktop_Path = @DesktopDir ; See if app is in Program Files If @ScriptDir = @ProgramFilesDir Then ; If app in Program Files need to save config files elsewhere If Not FileExists(@AppDataDir & "\ICF") Then DirCreate(@AppDataDir & "\ICF") $sConfig_Path = @AppDataDir & "\ICF" Else ; Can use working directory $sConfig_Path = @ScriptDir EndIf ; Get list of existing config files Global $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) #EndRegion ;----- Declarations ----- #Region ; ----- Command line ----- If $CmdLine[0] = 2 And StringLower($CmdLine[1]) = "restore" Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[Number($CmdLine[2])] If FileExists($sConfig_Name) Then _Set_Locations_Desktop() Exit EndIf #EndRegion ; ----- Command line ----- #Region ;----- Create GUI ----- Global $sGUITitle = "Icon Configuration Utility - 64bit version" If @OSArch = "X86" Then $sGUITitle = "Icon Configuration Utility - 32bit version" Global $hMain_GUI = GUICreate($sGUITitle, 370, 247) GUISetBkColor(0xFFFFFF) Global $hSave_Button = GUICtrlCreateButton("Save", 10, 175, 80, 25) Global $hRestore_Button = GUICtrlCreateButton("Restore", 100, 175, 80, 25) Global $hDelete_Button = GUICtrlCreateButton("Delete", 190, 175, 80, 25) Global $hAbout_Button = GUICtrlCreateButton("About", 280, 175, 80, 25) GUICtrlCreateLabel("List of icon configuration files (*.icf)", 10, 8, 200, 20) Global $hState_Label = GUICtrlCreateLabel("Ready", 280, 7, 80, 16, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xCCFFCC) GUICtrlCreateLabel("Command line restore via", 10, 210, 120, 13) GUICtrlSetFont(-1, 7, 400, 0, "Lucida Console") GUICtrlCreateLabel("icu.exe restore #", 10, 225, 120, 13) GUICtrlSetFont(-1, 7, 400, 0, "Lucida Console") GUICtrlCreateLabel("Move unknown icons", 152, 214, 110, 13) Global $cID_Combo_Unknown_Icon = GUICtrlCreateCombo("to position 0,0", 260, 210, 100, 20, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "off-screen|ask per icon") Global $hFile_List = GUICtrlCreateListView("#|Name|Date|Resolution", 10, 30, 350, 135, $LVS_SINGLESEL, $LVS_EX_FULLROWSELECT) ; Set up alt line colouring GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) ; Set col width _GUICtrlListView_SetColumnWidth(-1, 0, 20) _GUICtrlListView_SetColumnWidth(-1, 1, 117) _GUICtrlListView_SetColumnWidth(-1, 2, 145) _GUICtrlListView_SetColumnWidth(-1, 3, $LVSCW_AUTOSIZE_USEHEADER) If IsArray($aConfig_List) Then _Fill_ListView() Else GUICtrlCreateListViewItem("|No Files Found", $hFile_List) GUICtrlSetState($hRestore_Button, $GUI_DISABLE) EndIf GUISetState() #EndRegion ;----- Create GUI ----- #Region ;----- Main loop ----- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Opt("WinTitleMatchMode", $iOldOpt) Exit Case $hSave_Button _Save_Config() Case $hRestore_Button _Restore_Config() Case $hDelete_Button Global $iIndex = _GUICtrlListView_GetSelectedIndices($hFile_List, True) If $iIndex[0] = 1 Then If MsgBox(4 + 16, $sGUITitle, "Are you sure you want to delete """ & _GUICtrlListView_GetItemText($hFile_List, $iIndex[1], 1) & """") = 6 Then _Delete_Config() EndIf Case $hAbout_Button _On_Info() EndSwitch WEnd #EndRegion ;----- Main loop ----- ; Functions #Region ;----- Save ----- Func _Save_Config() Local $sConfig_Type = InputBox($sGUITitle, "Enter a name for the new icon configuration file:", Default, Default, 300, 130) If @error Then Return GUICtrlSetData($hState_Label, "Working") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get new config filename If IsArray($aConfig_List) Then Local $iNew_Index = $aConfig_List[0] + 1 $sConfig_Name = $sConfig_Path & "\IconConfigFile" & StringFormat("%03i", $iNew_Index) & ".icf" Else $sConfig_Name = $sConfig_Path & "\IconConfigFile001.icf" EndIf ; Write config file data IniWrite($sConfig_Name, "Data", "Type", $sConfig_Type) IniWrite($sConfig_Name, "Data", "Date", _NowCalc()) IniWrite($sConfig_Name, "Data", "Resolution", $aScreen_Res[2] & "x" & $aScreen_Res[3]) IniWrite($sConfig_Name, "Data", "Unknown_Icon_Handling", GUICtrlRead($cID_Combo_Unknown_Icon)) ; Save Desktop locations _Save_Locations_Desktop() ; Refill list _Fill_ListView() ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) GUICtrlSetState($hRestore_Button, $GUI_ENABLE) EndFunc ;==>_Save_Config ; ------------ Func _Save_Locations_Desktop() Local $hExplorer_List = ControlGetHandle("Program Manager", "", "SysListView321") ; Loop through folder contents For $i = 0 To _GUICtrlListView_GetItemCount($hExplorer_List) - 1 ; Get name Local $sKey_Name = _GUICtrlListView_GetItemText($hExplorer_List, $i) ; Get position Local $aPos = _GUICtrlListView_GetItemPosition($hExplorer_List, $i) Local $sValue_Pos = $aPos[0] & ":" & $aPos[1] ; Write to config file IniWrite($sConfig_Name, "Desktop", $sKey_Name, $sValue_Pos) Next EndFunc ;==>_Save_Locations_Desktop #EndRegion ;----- Save ----- #Region ;----- Restore ----- Func _Restore_Config() GUICtrlSetData($hState_Label, "Working") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get config file name Local $iIndex = GUICtrlRead($hFile_List) - $hList_Start If $iIndex > 0 Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[$iIndex] ; Restore Desktop _Set_Locations_Desktop() Else MsgBox(0, "Error", "No Configuration File Selected") EndIf ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) EndFunc ;==>_Restore_Config ; -------- Func _Set_Locations_Desktop() Local $hExplorer_List = ControlGetHandle("Program Manager", "", "SysListView321") GUICtrlSetData($cID_Combo_Unknown_Icon, IniRead($sConfig_Name, "Data", "Unknown_Icon_Handling", "to position 0,0")) ; Move all icons out of the viewable area to guarantee clear space for relocation ;~ For $i = 0 To _GUICtrlListView_GetItemCount($hExplorer_List) - 1 ;~ _GUICtrlListView_SetItemPosition($hExplorer_List, $i, $aScreen_Res[2], $aScreen_Res[3] + 100 * $i) ;~ Next ; Now replace icons back in stored positions For $j = 0 To 1 For $i = 0 To _GUICtrlListView_GetItemCount($hExplorer_List) - 1 ; Get name & position Local $sIcon_Name = _GUICtrlListView_GetItemText($hExplorer_List, $i) Local $sPos_Saved = IniRead($sConfig_Name, "Desktop", $sIcon_Name, "") If $sPos_Saved <> "" Then Local $aPos = StringSplit($sPos_Saved, ":") _GUICtrlListView_SetItemPosition($hExplorer_List, $i, $aPos[1], $aPos[2]) Else Switch GUICtrlRead($cID_Combo_Unknown_Icon) Case "off-screen" _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 9999, 9999) Case "ask per icon" Local $sAskAnswer = InputBox($sGUITitle, "Enter a position x,y", Default, Default, 300, 130) If @error Or Not StringInStr($sAskAnswer, ",") Then _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) Else Local $aAskAnswer = StringSplit($sAskAnswer, ",") If $aAskAnswer[0] = 2 Then _GUICtrlListView_SetItemPosition($hExplorer_List, $i, Number($aAskAnswer[1]), Number($aAskAnswer[2])) Else _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) EndIf EndIf Case Else _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) EndSwitch EndIf Next Next EndFunc ;==>_Set_Locations_Desktop #EndRegion ;----- Restore ----- #Region ;----- Delete ----- Func _Delete_Config() GUICtrlSetData($hState_Label, "Deleting") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get config file name Local $iIndex = GUICtrlRead($hFile_List) - $hList_Start If $iIndex > 0 Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[$iIndex] ; Delete config file FileRecycle($sConfig_Name) ; Renumber remaining config files $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) If IsArray($aConfig_List) Then For $i = 1 To $aConfig_List[0] Local $sSource = $sConfig_Path & "\" & $aConfig_List[$i] Local $sDest = $sConfig_Path & "\IconConfigFile" & StringFormat("%03i", $i) & ".icf" FileMove($sSource, $sDest) Next EndIf EndIf ; Refill list _Fill_ListView() ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) EndFunc ;==>_Delete_Config #EndRegion ;----- Delete ----- #Region ;----- Misc ----- Func _Fill_ListView() _GUICtrlListView_DeleteAllItems($hFile_List) ; Get list of files $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) ; Fill Listview If Not IsArray($aConfig_List) Then GUICtrlCreateListViewItem("|No Files Found", $hFile_List) GUICtrlSetState($hRestore_Button, $GUI_DISABLE) Return EndIf $hList_Start = GUICtrlCreateDummy() ; Start of list handles ; If > 9 files reduce final col size to leave place for v-scroll so no h-scroll If $aConfig_List[0] > 9 Then _GUICtrlListView_SetColumnWidth($hFile_List, 2, 95) ; Get data from files For $i = 1 To $aConfig_List[0] Local $sType = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Type", "Unknown") Local $sDate = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Date", "Unknown") Local $sRes = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Resolution", "Unknown") GUICtrlCreateListViewItem($i & "|" & $sType & "|" & $sDate & "|" & $sRes, $hFile_List) GUICtrlSetBkColor(-1, 0xCCFFCC) Next EndFunc ;==>_Fill_ListView #EndRegion ;----- Misc ----- #Region ;----- Info Functions ----- Func _On_Info() ;Show info messagebox MsgBox(4160, "About", "Icon Configuration Utility v2.0" & @CRLF & @CRLF & "Melba23 2009-2010, KaFu 2010") EndFunc ;==>_On_Info #EndRegion ;----- Info Functions -----Please test it!Regards,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
KaFu Posted January 14, 2010 Share Posted January 14, 2010 (edited) Two small things:- $aScreen_Res = WinGetPos($hScreen) needs to be called in _Save_Config() as the resolution is subject to change- the command line restore calls _Set_Locations_Desktop(), and in that function we are updating GUI controls... thus the command line call needs to be relocated to directly before the call of GuiSetState() or the scripts crashes with undefined variable (was already wrong in the initial script).expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Desktop.ico #AutoIt3Wrapper_outfile=ICU.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Description=Icon Configuration Utility #AutoIt3Wrapper_Res_Fileversion=2.0.0.0 #AutoIt3Wrapper_Res_LegalCopyright=Melba23 2009-2010, KaFu 2010 ://////=__= #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ; ##### Icon Configuration Utility ##### ; ; Script Version: 2.0 ; As at 13 Jan 10 ; #Region ;----- Includes ----- #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <ComboConstants.au3> #include <GuiListView.au3> #include <Date.au3> #include <File.au3> #EndRegion ;----- Includes ----- #Region ;----- Declarations ----- If Not @Compiled Then MsgBox(64, "ICU Info", "ICU needs to be compiled for full functionality") If @OSArch = "X64" And @AutoItX64 = 0 Then MsgBox(16, "ICU Error", "This version of ICU is 32-bit compiled" & @CRLF & _ "and will not run correctly with a 64-bit OS" & @CRLF & @CRLF & _ "Please recompile as a 64-bit executable") Exit EndIf Global $sConfig_Name, $sConfig_Path, $hList_Start, $aScreen_Res Global $hScreen = WinGetHandle("Program Manager") ; Match only exact window titles Global $iOldOpt = Opt("WinTitleMatchMode", 3) ; Set Desktop path Global $sDesktop_Path = @DesktopDir ; See if app is in Program Files If @ScriptDir = @ProgramFilesDir Then ; If app in Program Files need to save config files elsewhere If Not FileExists(@AppDataDir & "\ICF") Then DirCreate(@AppDataDir & "\ICF") $sConfig_Path = @AppDataDir & "\ICF" Else ; Can use working directory $sConfig_Path = @ScriptDir EndIf ; Get list of existing config files Global $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) #EndRegion ;----- Declarations ----- #Region ;----- Create GUI ----- Global $sGUITitle = "Icon Configuration Utility - 64bit version" If @OSArch = "X86" Then $sGUITitle = "Icon Configuration Utility - 32bit version" Global $hMain_GUI = GUICreate($sGUITitle, 370, 247) GUISetBkColor(0xFFFFFF) Global $hSave_Button = GUICtrlCreateButton("Save", 10, 175, 80, 25) Global $hRestore_Button = GUICtrlCreateButton("Restore", 100, 175, 80, 25) Global $hDelete_Button = GUICtrlCreateButton("Delete", 190, 175, 80, 25) Global $hAbout_Button = GUICtrlCreateButton("About", 280, 175, 80, 25) GUICtrlCreateLabel("List of icon configuration files (*.icf)", 10, 8, 200, 20) Global $hState_Label = GUICtrlCreateLabel("Ready", 280, 7, 80, 16, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xCCFFCC) GUICtrlCreateLabel("Command line restore via", 10, 210, 120, 13) GUICtrlSetFont(-1, 7, 400, 0, "Lucida Console") GUICtrlCreateLabel("icu.exe restore #", 10, 225, 120, 13) GUICtrlSetFont(-1, 7, 400, 0, "Lucida Console") GUICtrlCreateLabel("Move unknown icons", 152, 214, 110, 13) Global $cID_Combo_Unknown_Icon = GUICtrlCreateCombo("to position 0,0", 260, 210, 100, 20, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "off-screen|ask per icon") Global $hFile_List = GUICtrlCreateListView("#|Name|Date|Resolution", 10, 30, 350, 135, $LVS_SINGLESEL, $LVS_EX_FULLROWSELECT) ; Set up alt line colouring GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) ; Set col width _GUICtrlListView_SetColumnWidth(-1, 0, 20) _GUICtrlListView_SetColumnWidth(-1, 1, 117) _GUICtrlListView_SetColumnWidth(-1, 2, 145) _GUICtrlListView_SetColumnWidth(-1, 3, $LVSCW_AUTOSIZE_USEHEADER) If IsArray($aConfig_List) Then _Fill_ListView() Else GUICtrlCreateListViewItem("|No Files Found", $hFile_List) GUICtrlSetState($hRestore_Button, $GUI_DISABLE) EndIf #Region ; ----- Command line ----- If $CmdLine[0] = 2 And StringLower($CmdLine[1]) = "restore" Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[Number($CmdLine[2])] If FileExists($sConfig_Name) Then _Set_Locations_Desktop() Exit EndIf #EndRegion ; ----- Command line ----- GUISetState() #EndRegion ;----- Create GUI ----- #Region ;----- Main loop ----- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Opt("WinTitleMatchMode", $iOldOpt) Exit Case $hSave_Button _Save_Config() Case $hRestore_Button _Restore_Config() Case $hDelete_Button Global $iIndex = _GUICtrlListView_GetSelectedIndices($hFile_List, True) If $iIndex[0] = 1 Then If MsgBox(4 + 16, $sGUITitle, "Are you sure you want to delete """ & _GUICtrlListView_GetItemText($hFile_List, $iIndex[1], 1) & """") = 6 Then _Delete_Config() EndIf Case $hAbout_Button _On_Info() EndSwitch WEnd #EndRegion ;----- Main loop ----- ; Functions #Region ;----- Save ----- Func _Save_Config() Local $sConfig_Type = InputBox($sGUITitle, "Enter a name for the new icon configuration file:", Default, Default, 300, 130) If @error Then Return GUICtrlSetData($hState_Label, "Working") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get new config filename If IsArray($aConfig_List) Then Local $iNew_Index = $aConfig_List[0] + 1 $sConfig_Name = $sConfig_Path & "\IconConfigFile" & StringFormat("%03i", $iNew_Index) & ".icf" Else $sConfig_Name = $sConfig_Path & "\IconConfigFile001.icf" EndIf ; Write config file data $aScreen_Res = WinGetPos($hScreen) IniWrite($sConfig_Name, "Data", "Type", $sConfig_Type) IniWrite($sConfig_Name, "Data", "Date", _NowCalc()) IniWrite($sConfig_Name, "Data", "Resolution", $aScreen_Res[2] & "x" & $aScreen_Res[3]) IniWrite($sConfig_Name, "Data", "Unknown_Icon_Handling", GUICtrlRead($cID_Combo_Unknown_Icon)) ; Save Desktop locations _Save_Locations_Desktop() ; Refill list _Fill_ListView() ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) GUICtrlSetState($hRestore_Button, $GUI_ENABLE) EndFunc ;==>_Save_Config ; ------------ Func _Save_Locations_Desktop() Local $hExplorer_List = ControlGetHandle("Program Manager", "", "SysListView321") ; Loop through folder contents For $i = 0 To _GUICtrlListView_GetItemCount($hExplorer_List) - 1 ; Get name Local $sKey_Name = _GUICtrlListView_GetItemText($hExplorer_List, $i) ; Get position Local $aPos = _GUICtrlListView_GetItemPosition($hExplorer_List, $i) Local $sValue_Pos = $aPos[0] & ":" & $aPos[1] ; Write to config file IniWrite($sConfig_Name, "Desktop", $sKey_Name, $sValue_Pos) Next EndFunc ;==>_Save_Locations_Desktop #EndRegion ;----- Save ----- #Region ;----- Restore ----- Func _Restore_Config() GUICtrlSetData($hState_Label, "Working") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get config file name Local $iIndex = GUICtrlRead($hFile_List) - $hList_Start If $iIndex > 0 Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[$iIndex] ; Restore Desktop _Set_Locations_Desktop() Else MsgBox(0, "Error", "No Configuration File Selected") EndIf ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) EndFunc ;==>_Restore_Config ; -------- Func _Set_Locations_Desktop() Local $hExplorer_List = ControlGetHandle("Program Manager", "", "SysListView321") GUICtrlSetData($cID_Combo_Unknown_Icon, IniRead($sConfig_Name, "Data", "Unknown_Icon_Handling", "to position 0,0")) ; Now replace icons back in stored positions For $j = 0 To 1 For $i = 0 To _GUICtrlListView_GetItemCount($hExplorer_List) - 1 ; Get name & position Local $sIcon_Name = _GUICtrlListView_GetItemText($hExplorer_List, $i) Local $sPos_Saved = IniRead($sConfig_Name, "Desktop", $sIcon_Name, "") If $sPos_Saved <> "" Then Local $aPos = StringSplit($sPos_Saved, ":") _GUICtrlListView_SetItemPosition($hExplorer_List, $i, $aPos[1], $aPos[2]) Else Switch GUICtrlRead($cID_Combo_Unknown_Icon) Case "off-screen" _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 9999, 9999) Case "ask per icon" Local $sAskAnswer = InputBox($sGUITitle, "Enter a position x,y", Default, Default, 300, 130) If @error Or Not StringInStr($sAskAnswer, ",") Then _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) Else Local $aAskAnswer = StringSplit($sAskAnswer, ",") If $aAskAnswer[0] = 2 Then _GUICtrlListView_SetItemPosition($hExplorer_List, $i, Number($aAskAnswer[1]), Number($aAskAnswer[2])) Else _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) EndIf EndIf Case Else _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) EndSwitch EndIf Next Next EndFunc ;==>_Set_Locations_Desktop #EndRegion ;----- Restore ----- #Region ;----- Delete ----- Func _Delete_Config() GUICtrlSetData($hState_Label, "Deleting") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get config file name Local $iIndex = GUICtrlRead($hFile_List) - $hList_Start If $iIndex > 0 Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[$iIndex] ; Delete config file FileRecycle($sConfig_Name) ; Renumber remaining config files $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) If IsArray($aConfig_List) Then For $i = 1 To $aConfig_List[0] Local $sSource = $sConfig_Path & "\" & $aConfig_List[$i] Local $sDest = $sConfig_Path & "\IconConfigFile" & StringFormat("%03i", $i) & ".icf" FileMove($sSource, $sDest) Next EndIf EndIf ; Refill list _Fill_ListView() ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) EndFunc ;==>_Delete_Config #EndRegion ;----- Delete ----- #Region ;----- Misc ----- Func _Fill_ListView() _GUICtrlListView_DeleteAllItems($hFile_List) ; Get list of files $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) ; Fill Listview If Not IsArray($aConfig_List) Then GUICtrlCreateListViewItem("|No Files Found", $hFile_List) GUICtrlSetState($hRestore_Button, $GUI_DISABLE) Return EndIf $hList_Start = GUICtrlCreateDummy() ; Start of list handles ; If > 9 files reduce final col size to leave place for v-scroll so no h-scroll If $aConfig_List[0] > 9 Then _GUICtrlListView_SetColumnWidth($hFile_List, 2, 95) ; Get data from files For $i = 1 To $aConfig_List[0] Local $sType = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Type", "Unknown") Local $sDate = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Date", "Unknown") Local $sRes = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Resolution", "Unknown") GUICtrlCreateListViewItem($i & "|" & $sType & "|" & $sDate & "|" & $sRes, $hFile_List) GUICtrlSetBkColor(-1, 0xCCFFCC) Next EndFunc ;==>_Fill_ListView #EndRegion ;----- Misc ----- #Region ;----- Info Functions ----- Func _On_Info() ;Show info messagebox MsgBox(4160, "About", "Icon Configuration Utility v2.0" & @CRLF & @CRLF & "Melba23 2009-2010, KaFu 2010") EndFunc ;==>_On_Info #EndRegion ;----- Info Functions -----Edit: Now a three man effort , simple script with many tripwires. Thanks a lot and keep it up UEZ Edited January 14, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
UEZ Posted January 14, 2010 Share Posted January 14, 2010 (edited) Small update: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Desktop.ico #AutoIt3Wrapper_outfile=ICU.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Description=Icon Configuration Utility #AutoIt3Wrapper_Res_Fileversion=2.0.0.0 #AutoIt3Wrapper_Res_LegalCopyright=Melba23 2009-2010, KaFu 2010 ://////=__= #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ; ##### Icon Configuration Utility ##### ; ; Script Version: 2.0 ; As at 13 Jan 10 ; #Region ;----- Includes ----- #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <ComboConstants.au3> #include <GuiListView.au3> #include <Date.au3> #include <File.au3> #EndRegion ;----- Includes ----- #Region ;----- Declarations ----- If Not @Compiled Then MsgBox(64, "ICU Info", "ICU needs to be compiled for full functionality") If @OSArch = "X64" And @AutoItX64 = 0 Then MsgBox(16, "ICU Error", "This version of ICU is 32-bit compiled" & @CRLF & _ "and will not run correctly with a 64-bit OS" & @CRLF & @CRLF & _ "Please recompile as a 64-bit executable") Exit EndIf Global $sConfig_Name, $sConfig_Path, $hList_Start, $aScreen_Res Global $hScreen = WinGetHandle("Program Manager") ; Match only exact window titles Global $iOldOpt = Opt("WinTitleMatchMode", 3) ; Set Desktop path Global $sDesktop_Path = @DesktopDir ; See if app is in Program Files If @ScriptDir = @ProgramFilesDir Then ; If app in Program Files need to save config files elsewhere If Not FileExists(@AppDataDir & "\ICF") Then DirCreate(@AppDataDir & "\ICF") $sConfig_Path = @AppDataDir & "\ICF" Else ; Can use working directory $sConfig_Path = @ScriptDir EndIf ; Get list of existing config files Global $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) #EndRegion ;----- Declarations ----- #Region ;----- Create GUI ----- Global $sGUITitle = "Icon Configuration Utility - 64bit version" If @OSArch = "X86" Then $sGUITitle = "Icon Configuration Utility - 32bit version" Global $hMain_GUI = GUICreate($sGUITitle, 370, 247) GUISetBkColor(0xFFFFFF) Global $hSave_Button = GUICtrlCreateButton("Save", 10, 175, 80, 25) Global $hRestore_Button = GUICtrlCreateButton("Restore", 100, 175, 80, 25) Global $hDelete_Button = GUICtrlCreateButton("Delete", 190, 175, 80, 25) Global $hAbout_Button = GUICtrlCreateButton("About", 280, 175, 80, 25) GUICtrlCreateLabel("List of icon configuration files (*.icf)", 10, 8, 200, 20) Global $hState_Label = GUICtrlCreateLabel("Ready", 280, 7, 80, 16, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xCCFFCC) GUICtrlCreateLabel("Command line restore via", 10, 210, 120, 13) GUICtrlSetFont(-1, 7, 400, 0, "Lucida Console") GUICtrlCreateLabel("icu.exe restore #", 10, 225, 120, 13) GUICtrlSetFont(-1, 7, 400, 0, "Lucida Console") GUICtrlCreateLabel("Move unknown icons", 152, 214, 110, 13) Global $cID_Combo_Unknown_Icon = GUICtrlCreateCombo("to position 0,0", 260, 210, 100, 20, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "off-screen|ask per icon") Global $hFile_List = GUICtrlCreateListView("#|Name|Date|Resolution", 10, 30, 350, 135, $LVS_SINGLESEL, $LVS_EX_FULLROWSELECT) ; Set up alt line colouring GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) ; Set col width _GUICtrlListView_SetColumnWidth(-1, 0, 20) _GUICtrlListView_SetColumnWidth(-1, 1, 117) _GUICtrlListView_SetColumnWidth(-1, 2, 145) _GUICtrlListView_SetColumnWidth(-1, 3, $LVSCW_AUTOSIZE_USEHEADER) If IsArray($aConfig_List) Then _Fill_ListView() Else GUICtrlCreateListViewItem("|No Files Found", $hFile_List) GUICtrlSetState($hRestore_Button, $GUI_DISABLE) EndIf #Region ; ----- Command line ----- If $CmdLine[0] = 2 And StringLower($CmdLine[1]) = "restore" Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[Number($CmdLine[2])] If FileExists($sConfig_Name) Then _Set_Locations_Desktop() Exit EndIf #EndRegion ; ----- Command line ----- GUISetState() #EndRegion ;----- Create GUI ----- #Region ;----- Main loop ----- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Opt("WinTitleMatchMode", $iOldOpt) Exit Case $hSave_Button _Save_Config() Case $hRestore_Button _Restore_Config() Case $hDelete_Button Global $iIndex = _GUICtrlListView_GetSelectedIndices($hFile_List, True) If $iIndex[0] = 1 Then If MsgBox(4 + 16, $sGUITitle, "Are you sure you want to delete """ & _GUICtrlListView_GetItemText($hFile_List, $iIndex[1], 1) & """") = 6 Then _Delete_Config() EndIf Case $hAbout_Button _On_Info() EndSwitch WEnd #EndRegion ;----- Main loop ----- ; Functions #Region ;----- Save ----- Func _Save_Config() Local $sConfig_Type = InputBox($sGUITitle, "Enter a name for the new icon configuration file:", Default, Default, 300, 130) If @error Then Return GUICtrlSetData($hState_Label, "Working") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get new config filename If IsArray($aConfig_List) Then Local $iNew_Index = $aConfig_List[0] + 1 $sConfig_Name = $sConfig_Path & "\IconConfigFile" & StringFormat("%03i", $iNew_Index) & ".icf" Else $sConfig_Name = $sConfig_Path & "\IconConfigFile001.icf" EndIf ; Write config file data $aScreen_Res = WinGetPos($hScreen) IniWrite($sConfig_Name, "Data", "Type", $sConfig_Type) IniWrite($sConfig_Name, "Data", "Date", _NowCalc()) IniWrite($sConfig_Name, "Data", "Resolution", $aScreen_Res[2] & "x" & $aScreen_Res[3]) IniWrite($sConfig_Name, "Data", "Unknown_Icon_Handling", GUICtrlRead($cID_Combo_Unknown_Icon)) ; Save Desktop locations _Save_Locations_Desktop() ; Refill list _Fill_ListView() ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) GUICtrlSetState($hRestore_Button, $GUI_ENABLE) EndFunc ;==>_Save_Config ; ------------ Func _Save_Locations_Desktop() Local $hExplorer_List = ControlGetHandle("Program Manager", "", "SysListView321") ; Loop through folder contents For $i = 0 To _GUICtrlListView_GetItemCount($hExplorer_List) - 1 ; Get name Local $sKey_Name = _GUICtrlListView_GetItemText($hExplorer_List, $i) ; Get position Local $aPos = _GUICtrlListView_GetItemPosition($hExplorer_List, $i) Local $sValue_Pos = $aPos[0] & ":" & $aPos[1] ; Write to config file IniWrite($sConfig_Name, "Desktop", $sKey_Name, $sValue_Pos) Next EndFunc ;==>_Save_Locations_Desktop #EndRegion ;----- Save ----- #Region ;----- Restore ----- Func _Restore_Config() GUICtrlSetData($hState_Label, "Working") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get config file name Local $iIndex = GUICtrlRead($hFile_List) - $hList_Start If $iIndex > 0 Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[$iIndex] ; Restore Desktop _Set_Locations_Desktop() Else MsgBox(0, "Error", "No Configuration File Selected") EndIf ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) EndFunc ;==>_Restore_Config ; -------- Func _Set_Locations_Desktop() Local $hExplorer_List = ControlGetHandle("Program Manager", "", "SysListView321") GUICtrlSetData($cID_Combo_Unknown_Icon, IniRead($sConfig_Name, "Data", "Unknown_Icon_Handling", "to position 0,0")) ; Now replace icons back in stored positions Local $j = 0 While True For $i = 0 To _GUICtrlListView_GetItemCount($hExplorer_List) - 1 ; Get name & position Local $sIcon_Name = _GUICtrlListView_GetItemText($hExplorer_List, $i) Local $sPos_Saved = IniRead($sConfig_Name, "Desktop", $sIcon_Name, "") If $sPos_Saved <> "" Then Local $aPos = StringSplit($sPos_Saved, ":") _GUICtrlListView_SetItemPosition($hExplorer_List, $i, $aPos[1], $aPos[2]) Else Switch GUICtrlRead($cID_Combo_Unknown_Icon) Case "off-screen" _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 9999, 9999) Case "ask per icon" Local $sAskAnswer = InputBox($sGUITitle, "Enter a position x,y", Default, Default, 300, 130) If @error Or Not StringInStr($sAskAnswer, ",") Then _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) Else Local $aAskAnswer = StringSplit($sAskAnswer, ",") If $aAskAnswer[0] = 2 Then _GUICtrlListView_SetItemPosition($hExplorer_List, $i, Number($aAskAnswer[1]), Number($aAskAnswer[2])) Else _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) EndIf EndIf Case Else _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) EndSwitch $j += 1 EndIf Next $j += 1 If $j > 1 Then ExitLoop WEnd EndFunc ;==>_Set_Locations_Desktop #EndRegion ;----- Restore ----- #Region ;----- Delete ----- Func _Delete_Config() GUICtrlSetData($hState_Label, "Deleting") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get config file name Local $iIndex = GUICtrlRead($hFile_List) - $hList_Start If $iIndex > 0 Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[$iIndex] ; Delete config file FileRecycle($sConfig_Name) ; Renumber remaining config files $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) If IsArray($aConfig_List) Then For $i = 1 To $aConfig_List[0] Local $sSource = $sConfig_Path & "\" & $aConfig_List[$i] Local $sDest = $sConfig_Path & "\IconConfigFile" & StringFormat("%03i", $i) & ".icf" FileMove($sSource, $sDest) Next EndIf EndIf ; Refill list _Fill_ListView() ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) EndFunc ;==>_Delete_Config #EndRegion ;----- Delete ----- #Region ;----- Misc ----- Func _Fill_ListView() _GUICtrlListView_DeleteAllItems($hFile_List) ; Get list of files $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) ; Fill Listview If Not IsArray($aConfig_List) Then GUICtrlCreateListViewItem("|No Files Found", $hFile_List) GUICtrlSetState($hRestore_Button, $GUI_DISABLE) Return EndIf $hList_Start = GUICtrlCreateDummy() ; Start of list handles ; If > 9 files reduce final col size to leave place for v-scroll so no h-scroll If $aConfig_List[0] > 9 Then _GUICtrlListView_SetColumnWidth($hFile_List, 2, 95) ; Get data from files For $i = 1 To $aConfig_List[0] Local $sType = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Type", "Unknown") Local $sDate = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Date", "Unknown") Local $sRes = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Resolution", "Unknown") GUICtrlCreateListViewItem($i & "|" & $sType & "|" & $sDate & "|" & $sRes, $hFile_List) GUICtrlSetBkColor(-1, 0xCCFFCC) Next EndFunc ;==>_Fill_ListView #EndRegion ;----- Misc ----- #Region ;----- Info Functions ----- Func _On_Info() ;Show info messagebox MsgBox(4160, "About", "Icon Configuration Utility v2.0" & @CRLF & @CRLF & "Melba23 2009-2010, KaFu 2010") EndFunc ;==>_On_Info #EndRegion ;----- Info Functions ----- Just to avoid double entry procedure when entering a position x,y manually! UEZ PS: script is not my effort, just small modification ! Btw, nice idea! Edited January 14, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
KaFu Posted January 14, 2010 Share Posted January 14, 2010 Just to avoid double entry procedure when entering a position x,y manually! Good point! But the logic used in _Set_Locations_Desktop() didn't work, adjusted it a little: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Desktop.ico #AutoIt3Wrapper_Outfile=ICU.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Description=Icon Configuration Utility #AutoIt3Wrapper_Res_Fileversion=2.0.0.0 #AutoIt3Wrapper_Res_LegalCopyright=Melba23 2009-2010, KaFu 2010 ://////=__= #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ; ##### Icon Configuration Utility ##### ; ; Script Version: 2.0 ; As at 13 Jan 10 ; #Region ;----- Includes ----- #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <ComboConstants.au3> #include <GuiListView.au3> #include <Date.au3> #include <File.au3> #EndRegion ;----- Includes ----- #Region ;----- Declarations ----- If Not @Compiled Then MsgBox(64, "ICU Info", "ICU needs to be compiled for full functionality") If @OSArch = "X64" And @AutoItX64 = 0 Then MsgBox(16, "ICU Error", "This version of ICU is 32-bit compiled" & @CRLF & _ "and will not run correctly with a 64-bit OS" & @CRLF & @CRLF & _ "Please recompile as a 64-bit executable") Exit EndIf Global $sConfig_Name, $sConfig_Path, $hList_Start, $aScreen_Res Global $hScreen = WinGetHandle("Program Manager") ; Match only exact window titles Global $iOldOpt = Opt("WinTitleMatchMode", 3) ; Set Desktop path Global $sDesktop_Path = @DesktopDir ; See if app is in Program Files If @ScriptDir = @ProgramFilesDir Then ; If app in Program Files need to save config files elsewhere If Not FileExists(@AppDataDir & "\ICF") Then DirCreate(@AppDataDir & "\ICF") $sConfig_Path = @AppDataDir & "\ICF" Else ; Can use working directory $sConfig_Path = @ScriptDir EndIf ; Get list of existing config files Global $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) #EndRegion ;----- Declarations ----- #Region ;----- Create GUI ----- Global $sGUITitle = "Icon Configuration Utility - 64bit version" If @OSArch = "X86" Then $sGUITitle = "Icon Configuration Utility - 32bit version" Global $hMain_GUI = GUICreate($sGUITitle, 370, 247) GUISetBkColor(0xFFFFFF) Global $hSave_Button = GUICtrlCreateButton("Save", 10, 175, 80, 25) Global $hRestore_Button = GUICtrlCreateButton("Restore", 100, 175, 80, 25) Global $hDelete_Button = GUICtrlCreateButton("Delete", 190, 175, 80, 25) Global $hAbout_Button = GUICtrlCreateButton("About", 280, 175, 80, 25) GUICtrlCreateLabel("List of icon configuration files (*.icf)", 10, 8, 200, 20) Global $hState_Label = GUICtrlCreateLabel("Ready", 280, 7, 80, 16, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xCCFFCC) GUICtrlCreateLabel("Command line restore via", 10, 210, 120, 13) GUICtrlSetFont(-1, 7, 400, 0, "Lucida Console") GUICtrlCreateLabel("icu.exe restore #", 10, 225, 120, 13) GUICtrlSetFont(-1, 7, 400, 0, "Lucida Console") GUICtrlCreateLabel("Move unknown icons", 152, 214, 110, 13) Global $cID_Combo_Unknown_Icon = GUICtrlCreateCombo("to position 0,0", 260, 210, 100, 20, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "off-screen|ask per icon") Global $hFile_List = GUICtrlCreateListView("#|Name|Date|Resolution", 10, 30, 350, 135, $LVS_SINGLESEL, $LVS_EX_FULLROWSELECT) ; Set up alt line colouring GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) ; Set col width _GUICtrlListView_SetColumnWidth(-1, 0, 20) _GUICtrlListView_SetColumnWidth(-1, 1, 117) _GUICtrlListView_SetColumnWidth(-1, 2, 145) _GUICtrlListView_SetColumnWidth(-1, 3, $LVSCW_AUTOSIZE_USEHEADER) If IsArray($aConfig_List) Then _Fill_ListView() Else GUICtrlCreateListViewItem("|No Files Found", $hFile_List) GUICtrlSetState($hRestore_Button, $GUI_DISABLE) EndIf #Region ; ----- Command line ----- If $CmdLine[0] = 2 And StringLower($CmdLine[1]) = "restore" Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[Number($CmdLine[2])] If FileExists($sConfig_Name) Then _Set_Locations_Desktop() Exit EndIf #EndRegion ; ----- Command line ----- GUISetState() #EndRegion ;----- Create GUI ----- #Region ;----- Main loop ----- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Opt("WinTitleMatchMode", $iOldOpt) Exit Case $hSave_Button _Save_Config() Case $hRestore_Button _Restore_Config() Case $hDelete_Button Global $iIndex = _GUICtrlListView_GetSelectedIndices($hFile_List, True) If $iIndex[0] = 1 Then If MsgBox(4 + 16, $sGUITitle, "Are you sure you want to delete """ & _GUICtrlListView_GetItemText($hFile_List, $iIndex[1], 1) & """") = 6 Then _Delete_Config() EndIf Case $hAbout_Button _On_Info() EndSwitch WEnd #EndRegion ;----- Main loop ----- ; Functions #Region ;----- Save ----- Func _Save_Config() Local $sConfig_Type = InputBox($sGUITitle, "Enter a name for the new icon configuration file:", Default, Default, 300, 130) If @error Then Return GUICtrlSetData($hState_Label, "Working") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get new config filename If IsArray($aConfig_List) Then Local $iNew_Index = $aConfig_List[0] + 1 $sConfig_Name = $sConfig_Path & "\IconConfigFile" & StringFormat("%03i", $iNew_Index) & ".icf" Else $sConfig_Name = $sConfig_Path & "\IconConfigFile001.icf" EndIf ; Write config file data $aScreen_Res = WinGetPos($hScreen) IniWrite($sConfig_Name, "Data", "Type", $sConfig_Type) IniWrite($sConfig_Name, "Data", "Date", _NowCalc()) IniWrite($sConfig_Name, "Data", "Resolution", $aScreen_Res[2] & "x" & $aScreen_Res[3]) IniWrite($sConfig_Name, "Data", "Unknown_Icon_Handling", GUICtrlRead($cID_Combo_Unknown_Icon)) ; Save Desktop locations _Save_Locations_Desktop() ; Refill list _Fill_ListView() ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) GUICtrlSetState($hRestore_Button, $GUI_ENABLE) EndFunc ;==>_Save_Config ; ------------ Func _Save_Locations_Desktop() Local $hExplorer_List = ControlGetHandle("Program Manager", "", "SysListView321") ; Loop through folder contents For $i = 0 To _GUICtrlListView_GetItemCount($hExplorer_List) - 1 ; Get name Local $sKey_Name = _GUICtrlListView_GetItemText($hExplorer_List, $i) ; Get position Local $aPos = _GUICtrlListView_GetItemPosition($hExplorer_List, $i) Local $sValue_Pos = $aPos[0] & ":" & $aPos[1] ; Write to config file IniWrite($sConfig_Name, "Desktop", $sKey_Name, $sValue_Pos) Next EndFunc ;==>_Save_Locations_Desktop #EndRegion ;----- Save ----- #Region ;----- Restore ----- Func _Restore_Config() GUICtrlSetData($hState_Label, "Working") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get config file name Local $iIndex = GUICtrlRead($hFile_List) - $hList_Start If $iIndex > 0 Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[$iIndex] ; Restore Desktop _Set_Locations_Desktop() Else MsgBox(0, "Error", "No Configuration File Selected") EndIf ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) EndFunc ;==>_Restore_Config ; -------- Func _Set_Locations_Desktop() Local $hExplorer_List = ControlGetHandle("Program Manager", "", "SysListView321") GUICtrlSetData($cID_Combo_Unknown_Icon, IniRead($sConfig_Name, "Data", "Unknown_Icon_Handling", "to position 0,0")) ; Now replace icons back in stored positions Local $j = 0, $sAskAnswer While True For $i = 0 To _GUICtrlListView_GetItemCount($hExplorer_List) - 1 ; Get name & position Local $sIcon_Name = _GUICtrlListView_GetItemText($hExplorer_List, $i) Local $sPos_Saved = IniRead($sConfig_Name, "Desktop", $sIcon_Name, "") If $sPos_Saved <> "" Then Local $aPos = StringSplit($sPos_Saved, ":") _GUICtrlListView_SetItemPosition($hExplorer_List, $i, $aPos[1], $aPos[2]) Else Switch GUICtrlRead($cID_Combo_Unknown_Icon) Case "off-screen" _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 9999, 9999) Case "ask per icon" If $j = 0 Then $sAskAnswer = InputBox($sGUITitle, "Enter a position x,y", Default, Default, 300, 130) If @error Or Not StringInStr($sAskAnswer, ",") Then _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) Else Local $aAskAnswer = StringSplit($sAskAnswer, ",") If $aAskAnswer[0] = 2 Then _GUICtrlListView_SetItemPosition($hExplorer_List, $i, Number($aAskAnswer[1]), Number($aAskAnswer[2])) Else _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) EndIf EndIf Case Else _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) EndSwitch EndIf Next $j += 1 If $j = 2 Then ExitLoop WEnd EndFunc ;==>_Set_Locations_Desktop #EndRegion ;----- Restore ----- #Region ;----- Delete ----- Func _Delete_Config() GUICtrlSetData($hState_Label, "Deleting") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get config file name Local $iIndex = GUICtrlRead($hFile_List) - $hList_Start If $iIndex > 0 Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[$iIndex] ; Delete config file FileRecycle($sConfig_Name) ; Renumber remaining config files $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) If IsArray($aConfig_List) Then For $i = 1 To $aConfig_List[0] Local $sSource = $sConfig_Path & "\" & $aConfig_List[$i] Local $sDest = $sConfig_Path & "\IconConfigFile" & StringFormat("%03i", $i) & ".icf" FileMove($sSource, $sDest) Next EndIf EndIf ; Refill list _Fill_ListView() ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) EndFunc ;==>_Delete_Config #EndRegion ;----- Delete ----- #Region ;----- Misc ----- Func _Fill_ListView() _GUICtrlListView_DeleteAllItems($hFile_List) ; Get list of files $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) ; Fill Listview If Not IsArray($aConfig_List) Then GUICtrlCreateListViewItem("|No Files Found", $hFile_List) GUICtrlSetState($hRestore_Button, $GUI_DISABLE) Return EndIf $hList_Start = GUICtrlCreateDummy() ; Start of list handles ; If > 9 files reduce final col size to leave place for v-scroll so no h-scroll If $aConfig_List[0] > 9 Then _GUICtrlListView_SetColumnWidth($hFile_List, 2, 95) ; Get data from files For $i = 1 To $aConfig_List[0] Local $sType = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Type", "Unknown") Local $sDate = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Date", "Unknown") Local $sRes = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Resolution", "Unknown") GUICtrlCreateListViewItem($i & "|" & $sType & "|" & $sDate & "|" & $sRes, $hFile_List) GUICtrlSetBkColor(-1, 0xCCFFCC) Next EndFunc ;==>_Fill_ListView #EndRegion ;----- Misc ----- #Region ;----- Info Functions ----- Func _On_Info() ;Show info messagebox MsgBox(4160, "About", "Icon Configuration Utility v2.0" & @CRLF & @CRLF & "Melba23 2009-2010, KaFu 2010") EndFunc ;==>_On_Info #EndRegion ;----- Info Functions ----- OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
nitekram Posted January 20, 2010 Share Posted January 20, 2010 Have a small problem - on domain, windows xp sp 3, running two monitors (extended desktop) - also tried with only one desktop used the program to take a copy of where all icons were, replaced, logged off and logged back on - icons do not go back to where they were to begin with - just randomized on desktop Any clues? 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
nitekram Posted January 20, 2010 Share Posted January 20, 2010 Found another issue - when you open explorer and go to tools and then Folder Options and then change a file type the icons all go back to randomized. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
KaFu Posted January 21, 2010 Share Posted January 21, 2010 used the program to take a copy of where all icons were, replaced, logged off and logged back on - icons do not go back to where they were to begin with - just randomized on desktopICU does not automatically restore the position. You have to either click "restore" or call "icu.exe restore 1" (where 1 is the first config file).Found another issue - when you open explorer and go to tools and then Folder Options and then change a file type the icons all go back to randomized.Did you press restore? Error sounds strange to me. If this doesn't solve your problem, maybe PM me respective IconConfigFile*.icf file and I'll take a look. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Apzo Posted January 22, 2010 Share Posted January 22, 2010 (edited) Simple question... Is it possible to have some basic functions in an UDF such as - GetDesktopInconList() - IconGetPos() - IconSetPos($xPos, $Ypos) Thanks Apzo. Edited January 22, 2010 by Apzo All the pop3 functions.Rsync your files on your USB key (or anywhere else) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 23, 2010 Author Moderators Share Posted January 23, 2010 Apzo,Is it possible to have some basic functions in an UDF - GetDesktopIconList(), IconGetPos(), IconSetPos($xPos, $Ypos)?Yes. Will we write it for you? No.All the functionality you are asking for is within this UDF. Feel free to extract the relevant sections and put them in your own wrapper so you can have the functions you want easily available. M23P.S. And please post it in the Examples section when you have finished so others can share! Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
taz742 Posted February 5, 2010 Share Posted February 5, 2010 Nice app BTW I just made little change by replacing: If @OSArch = "X86" Then $sGUITitle = "Icon Configuration Utility - 32bit version" by this one: If @AutoItX64 = 0 Then $sGUITitle = "Icon Configuration Utility - 32bit version" Link to comment Share on other sites More sharing options...
JoeCool Posted February 8, 2010 Share Posted February 8, 2010 cool exactly what i was looking for ! thanks a lot guys ! i found a small bug ... but it's not only your fault ... sometime i go to other forums ... (it's a shame i'm not often here) :oP and i like to drag and drop the webbrowser link of interesting message on my desktop ... so in some sites like Ubuntu forum the thread link title start often with [ubuntu] Hello world blah blah so when i save the link on my desktop, the shortcut name is also [ubuntu] Hello world blah blah that is not save correctly into you .ini file [ubuntu] become of an .ini section. ... maybe some error / warning message could be useful. another improvement maybe, config file name could reflect the name in the gui ex. IconConfigFile003.icf doesn't reflet my guiname "blahblah" inside GUI, sugg, IconConfigFile003blahblah.icf so i can easily restore from command line the right layout without searching alot into files. but hey ur thing is great ! Link to comment Share on other sites More sharing options...
KaFu Posted February 8, 2010 Share Posted February 8, 2010 [ubuntu] become of an .ini section. ... You're right, thanks for the feedback ... the same will happen if the name contains a "=", will add a string replacement for theses cases... sugg, IconConfigFile003blahblah.icf Makes sense too , and additionally there should be a position prefix 2_, 3_ etc. which does not change when you're deleting e.g. 1_ or else command-line calls will target the wrong config-file. Will add that too ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
KaFu Posted February 14, 2010 Share Posted February 14, 2010 (edited) Version 2.3Added _URIEncode() function to make icon filenames save for iniwrite / inireadName of the config file is now saved as part of the filenameConfig filenames are not re-enumerated if a file is deletedIllegal filename characters in config name are deleted automaticallyCheck it out and let me know any shortcomings ...Edit: Fixed an error, if ICU was called with non-existing config set number via command line-expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Desktop.ico #AutoIt3Wrapper_outfile=ICU.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Description=Icon Configuration Utility #AutoIt3Wrapper_Res_Fileversion=2.3.0.0 #AutoIt3Wrapper_Res_LegalCopyright=Melba23 2009-2010, KaFu 2010 ://////=__= #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ; ##### Icon Configuration Utility ##### ; ; Script Version: 2.3 ; As at 15 Feb 10 ; #Region ;----- Includes ----- #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <ComboConstants.au3> #include <GuiListView.au3> #include <Date.au3> #include <File.au3> #EndRegion ;----- Includes ----- #Region ;----- Declarations ----- If Not @Compiled Then MsgBox(64, "ICU Info", "ICU needs to be compiled for full functionality") If @OSArch = "X64" And @AutoItX64 = 0 Then MsgBox(16, "ICU Error", "This version of ICU is 32-bit compiled" & @CRLF & _ "and will not run correctly with a 64-bit OS" & @CRLF & @CRLF & _ "Please recompile as a 64-bit executable") Exit EndIf Global $sConfig_Name, $sConfig_Path, $hList_Start, $aScreen_Res Global $hScreen = WinGetHandle("Program Manager") ; Match only exact window titles Global $iOldOpt = Opt("WinTitleMatchMode", 3) ; Set Desktop path Global $sDesktop_Path = @DesktopDir ; See if app is in Program Files If @ScriptDir = @ProgramFilesDir Then ; If app in Program Files need to save config files elsewhere If Not FileExists(@AppDataDir & "\ICF") Then DirCreate(@AppDataDir & "\ICF") $sConfig_Path = @AppDataDir & "\ICF" Else ; Can use working directory $sConfig_Path = @ScriptDir EndIf ; Get list of existing config files Global $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) #EndRegion ;----- Declarations ----- #Region ;----- Create GUI ----- Global $sGUITitle = "Icon Configuration Utility - 64bit version" If @AutoItX64 = 0 Then $sGUITitle = "Icon Configuration Utility - 32bit version" Global $hMain_GUI = GUICreate($sGUITitle, 370, 247) GUISetBkColor(0xFFFFFF) Global $hSave_Button = GUICtrlCreateButton("Save", 10, 175, 80, 25) Global $hRestore_Button = GUICtrlCreateButton("Restore", 100, 175, 80, 25) Global $hDelete_Button = GUICtrlCreateButton("Delete", 190, 175, 80, 25) Global $hAbout_Button = GUICtrlCreateButton("About", 280, 175, 80, 25) GUICtrlCreateLabel("List of icon configuration files (*.icf)", 10, 8, 200, 20) Global $hState_Label = GUICtrlCreateLabel("Ready", 280, 7, 80, 16, $SS_CENTER + $SS_CENTERIMAGE) GUICtrlSetBkColor(-1, 0xCCFFCC) GUICtrlCreateLabel("Command line restore via", 10, 210, 120, 13) GUICtrlSetFont(-1, 7, 400, 0, "Lucida Console") GUICtrlCreateLabel("icu.exe restore #", 10, 225, 120, 13) GUICtrlSetFont(-1, 7, 400, 0, "Lucida Console") GUICtrlCreateLabel("Move unknown icons", 152, 214, 110, 13) Global $cID_Combo_Unknown_Icon = GUICtrlCreateCombo("to position 0,0", 260, 210, 100, 20, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "off-screen|ask per icon") Global $hFile_List = GUICtrlCreateListView("#|Name|Date|Resolution", 10, 30, 350, 135, $LVS_SINGLESEL, $LVS_EX_FULLROWSELECT) ; Set up alt line colouring GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) ; Set col width _GUICtrlListView_SetColumnWidth(-1, 0, 20) _GUICtrlListView_SetColumnWidth(-1, 1, 117) _GUICtrlListView_SetColumnWidth(-1, 2, 145) _GUICtrlListView_SetColumnWidth(-1, 3, $LVSCW_AUTOSIZE_USEHEADER) If IsArray($aConfig_List) Then _Fill_ListView() Else GUICtrlCreateListViewItem("|No Files Found", $hFile_List) GUICtrlSetState($hRestore_Button, $GUI_DISABLE) EndIf #Region ; ----- Command line ----- If $CmdLine[0] = 2 And StringLower($CmdLine[1]) = "restore" Then If Not IsArray($aConfig_List) Then Exit For $i = 1 To $aConfig_List[0] If Number(StringLeft($aConfig_List[$i], 3)) = Number($CmdLine[2]) Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[$i] If FileExists($sConfig_Name) Then _Set_Locations_Desktop() Exit EndIf Next MsgBox(64 + 262144, "ICU", "ICU could not find called config # " & $CmdLine[2]) Exit EndIf #EndRegion ; ----- Command line ----- GUISetState() #EndRegion ;----- Create GUI ----- #Region ;----- Main loop ----- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Opt("WinTitleMatchMode", $iOldOpt) Exit Case $hSave_Button _Save_Config() Case $hRestore_Button _Restore_Config() Case $hDelete_Button Global $iIndex = _GUICtrlListView_GetSelectedIndices($hFile_List, True) If $iIndex[0] = 1 Then If MsgBox(4 + 16, $sGUITitle, "Are you sure you want to delete """ & _GUICtrlListView_GetItemText($hFile_List, $iIndex[1], 1) & """") = 6 Then _Delete_Config() EndIf Case $hAbout_Button _On_Info() EndSwitch WEnd #EndRegion ;----- Main loop ----- ; Functions #Region ;----- Save ----- Func _Save_Config() Local $sConfig_Type = InputBox($sGUITitle, "Enter a name for the new icon configuration file:", Default, Default, 300, 130) If @error Then Return $sConfig_Type = StringRegExpReplace($sConfig_Type, '[\Q\/:?*"<>|\E]', '') ; force valid filename GUICtrlSetData($hState_Label, "Working") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get new config filename If IsArray($aConfig_List) Then Local $iNew_Index = 0 For $i = 0 To UBound($aConfig_List) - 1 If Number(StringLeft($aConfig_List[$i], 3)) >= $iNew_Index Then $iNew_Index = Number(StringLeft($aConfig_List[$i], 3)) + 1 Next $sConfig_Name = $sConfig_Path & "\" & StringFormat("%03i", $iNew_Index) & "_" & $sConfig_Type & ".icf" Else $sConfig_Name = $sConfig_Path & "\001_" & $sConfig_Type & ".icf" EndIf ; Write config file data $aScreen_Res = WinGetPos($hScreen) IniWrite($sConfig_Name, "Data", "Type", $sConfig_Type) IniWrite($sConfig_Name, "Data", "Date", _NowCalc()) IniWrite($sConfig_Name, "Data", "Resolution", $aScreen_Res[2] & "x" & $aScreen_Res[3]) IniWrite($sConfig_Name, "Data", "Unknown_Icon_Handling", GUICtrlRead($cID_Combo_Unknown_Icon)) ; Save Desktop locations _Save_Locations_Desktop() ; Refill list _Fill_ListView() ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) GUICtrlSetState($hRestore_Button, $GUI_ENABLE) EndFunc ;==>_Save_Config ; ------------ Func _Save_Locations_Desktop() Local $hExplorer_List = ControlGetHandle("Program Manager", "", "SysListView321") ; Loop through folder contents For $i = 0 To _GUICtrlListView_GetItemCount($hExplorer_List) - 1 ; Get name Local $sKey_Name = _GUICtrlListView_GetItemText($hExplorer_List, $i) ; Get position Local $aPos = _GUICtrlListView_GetItemPosition($hExplorer_List, $i) Local $sValue_Pos = $aPos[0] & ":" & $aPos[1] ; Write to config file IniWrite($sConfig_Name, "Desktop", _URIEncode($sKey_Name), $sValue_Pos) Next EndFunc ;==>_Save_Locations_Desktop #EndRegion ;----- Save ----- #Region ;----- Restore ----- Func _Restore_Config() GUICtrlSetData($hState_Label, "Working") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get config file name Local $iIndex = GUICtrlRead($hFile_List) - $hList_Start If $iIndex > 0 Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[$iIndex] ; Restore Desktop _Set_Locations_Desktop() Else MsgBox(0, "Error", "No Configuration File Selected") EndIf ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) EndFunc ;==>_Restore_Config ; -------- Func _Set_Locations_Desktop() Local $hExplorer_List = ControlGetHandle("Program Manager", "", "SysListView321") GUICtrlSetData($cID_Combo_Unknown_Icon, IniRead($sConfig_Name, "Data", "Unknown_Icon_Handling", "to position 0,0")) ; Now replace icons back in stored positions Local $j = 0, $sAskAnswer While True For $i = 0 To _GUICtrlListView_GetItemCount($hExplorer_List) - 1 ; Get name & position Local $sIcon_Name = _GUICtrlListView_GetItemText($hExplorer_List, $i) Local $sPos_Saved = IniRead($sConfig_Name, "Desktop", _URIEncode($sIcon_Name), "") If $sPos_Saved <> "" Then Local $aPos = StringSplit($sPos_Saved, ":") _GUICtrlListView_SetItemPosition($hExplorer_List, $i, $aPos[1], $aPos[2]) Else Switch GUICtrlRead($cID_Combo_Unknown_Icon) Case "off-screen" _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 9999, 9999) Case "ask per icon" If $j = 0 Then $sAskAnswer = InputBox($sGUITitle, "Enter a position x,y", Default, Default, 300, 130) If @error Or Not StringInStr($sAskAnswer, ",") Then _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) Else Local $aAskAnswer = StringSplit($sAskAnswer, ",") If $aAskAnswer[0] = 2 Then _GUICtrlListView_SetItemPosition($hExplorer_List, $i, Number($aAskAnswer[1]), Number($aAskAnswer[2])) Else _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) EndIf EndIf Case Else _GUICtrlListView_SetItemPosition($hExplorer_List, $i, 0, 0) EndSwitch EndIf Next $j += 1 If $j = 2 Then ExitLoop WEnd EndFunc ;==>_Set_Locations_Desktop #EndRegion ;----- Restore ----- #Region ;----- Delete ----- Func _Delete_Config() GUICtrlSetData($hState_Label, "Deleting") GUICtrlSetBkColor($hState_Label, 0xCC0000) ; Get config file name Local $iIndex = GUICtrlRead($hFile_List) - $hList_Start If $iIndex > 0 Then $sConfig_Name = $sConfig_Path & "\" & $aConfig_List[$iIndex] ; Delete config file FileRecycle($sConfig_Name) EndIf ; Refill list _Fill_ListView() ; Reset GUI GUICtrlSetData($hState_Label, "Ready") GUICtrlSetBkColor($hState_Label, 0xCCFFCC) EndFunc ;==>_Delete_Config #EndRegion ;----- Delete ----- #Region ;----- Misc ----- Func _Fill_ListView() _GUICtrlListView_DeleteAllItems($hFile_List) ; Get list of files $aConfig_List = _FileListToArray($sConfig_Path, "*.icf", 1) ; Fill Listview If Not IsArray($aConfig_List) Then GUICtrlCreateListViewItem("|No Files Found", $hFile_List) GUICtrlSetState($hRestore_Button, $GUI_DISABLE) Return EndIf $hList_Start = GUICtrlCreateDummy() ; Start of list handles ; If > 9 files reduce final col size to leave place for v-scroll so no h-scroll If $aConfig_List[0] > 9 Then _GUICtrlListView_SetColumnWidth($hFile_List, 2, 95) ; Get data from files For $i = 1 To $aConfig_List[0] Local $sType = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Type", "Unknown") Local $sDate = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Date", "Unknown") Local $sRes = IniRead($sConfig_Path & "\" & $aConfig_List[$i], "Data", "Resolution", "Unknown") GUICtrlCreateListViewItem(Number(StringLeft($aConfig_List[$i], 3)) & "|" & $sType & "|" & $sDate & "|" & $sRes, $hFile_List) GUICtrlSetBkColor(-1, 0xCCFFCC) Next EndFunc ;==>_Fill_ListView #EndRegion ;----- Misc ----- #Region ;----- Info Functions ----- Func _On_Info() ;Show info messagebox MsgBox(4160, "About", "Icon Configuration Utility v2.2" & @CRLF & @CRLF & "Melba23 2009-2010, KaFu 2010") EndFunc ;==>_On_Info #EndRegion ;----- Info Functions ----- ; #FUNCTION# ==================================================================================================================== ; Name...........: _URIEncode ; Description ...: Encodes a string to be used in an URI ; Syntax.........: _URIEncode($sData) ; Parameters ....: $sData - String to encode ; Return values .: Encoded String ; Author ........: Prog@ndy ; Modified.......: ; Remarks .......: This function uses UTF-8 encoding for special chars ; Related .......: _URIDecode ; Link ..........; ; Example .......; ; =============================================================================================================================== Func _URIEncode($sData) ; Prog@ndy Local $aData = StringSplit(BinaryToString(StringToBinary($sData, 4), 1), "") Local $nChar $sData = "" For $i = 1 To $aData[0] ;~ ConsoleWrite($aData[$i] & @CRLF) $nChar = Asc($aData[$i]) Switch $nChar Case 45, 46, 48 - 57, 65 To 90, 95, 97 To 122, 126 $sData &= $aData[$i] Case 32 $sData &= "+" Case Else $sData &= "%" & Hex($nChar, 2) EndSwitch Next Return $sData EndFunc ;==>_URIEncode Func _URIDecode($sData) ; Prog@ndy Local $aData = StringSplit(StringReplace($sData, "+", " ", 0, 1), "%") $sData = "" For $i = 2 To $aData[0] $aData[1] &= Chr(Dec(StringLeft($aData[$i], 2))) & StringTrimLeft($aData[$i], 2) Next Return BinaryToString(StringToBinary($aData[1], 1), 4) EndFunc ;==>_URIDecode Edited February 15, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) 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