CodeHog Posted Monday at 10:09 PM Posted Monday at 10:09 PM (edited) Windows' "Change Icon" dialog (Shortcut Properties > Change Icon) often initially opens its Browse dialog to the crusty Windows XP-era icons in %SystemRoot%\System32\SHELL32.dll. That's not configurable in Windows itself - but the dialog reads its "starting folder" from whatever path is currently typed in its filename textbox. This script watches for the "Change Icon" window and pre-fills that textbox with your custom icon folder, which in my case is C:\Icons, so when you click "Browse..." it opens there instead. Thanks to some chatbox guidance. I updated script to assign it the "esc" hotkey to terminate the program so that you can launch it, when needed with your preferred hotkey and terminate it with the "esc" key. expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.18.0 Author: BYTE-ME PURPOSE: Windows' "Change Icon" dialog (Shortcut Properties > Change Icon) always opens its Browse dialog in C:\Windows\System32. That's not configurable in Windows itself - but the dialog reads its "starting folder" from whatever path is currently typed in its filename textbox. This script watches for the "Change Icon" window and pre-fills that textbox with your custom icon folder, so when you click "Browse..." it opens there instead. Script Function: Set Icon Path 1. Edit $sIconFolder below if C:\Icons isn't your path. 2. Double-click the .au3, or compile it to an .exe with Aut2Exe and put it in your Startup folder so it's always running). 3. Right-click a shortcut > Properties > Change Icon... The textbox will auto-fill with your folder. Click "Browse..." and it will open directly in C:\Icons. 4. If auto-detection doesn't fire (dialog/control names differ on your Windows build), use the manual hotkey: Ctrl+Alt+I while the Change Icon dialog is focused. 5. Upon activation, the script now displays a custom tray icon to indicate the script is active and to alert user that hitting the "esc" key will terminate the script. #ce ---------------------------------------------------------------------------- #RequireAdmin #include <WinAPI.au3> #include <TrayConstants.au3> Global $sIconFolder = "C:\Icons\" ; <-- change this if needed Global $sDialogTitle = "Change Icon" Global $sEditControl = "Edit1" ; textbox holding the icon path Global $hLastHandled = 0 Global $bRunning = True ; --- Tray setup --- Opt("TrayMenuMode", 1) ; default menu items off, we build our own TraySetIcon("C:\Icons\Icon1.ico") TraySetToolTip("Icon Path Filler - Active (Esc to stop)") TraySetState($TRAY_ICONSTATE_SHOW) Global $idExitItem = TrayCreateItem("Exit") TrayCreateItem("") ; separator ; One-time popup notification on launch TrayTip("Icon Path Filler", "Script is now active. Press Esc to stop.", 5, 1) ; Hotkeys HotKeySet("^!i", "_FillIconFolder") ; manual fallback HotKeySet("{ESC}", "_StopScript") ; kill switch While $bRunning Local $hWnd = WinGetHandle($sDialogTitle) If Not @error Then If $hWnd <> $hLastHandled Then _FillIconFolder() $hLastHandled = $hWnd EndIf Else $hLastHandled = 0 EndIf ; Check tray menu clicks too Switch TrayGetMsg() Case $idExitItem _StopScript() EndSwitch Sleep(250) WEnd Func _FillIconFolder() Local $hWnd = WinGetHandle($sDialogTitle) If @error Then Return Local $hCtrl = ControlGetHandle($hWnd, "", $sEditControl) If @error Or Not $hCtrl Then ; Control name didn't match on this Windows build. ; Open "AutoIt Window Info" to find the correct ClassNN ; and update $sEditControl above. Return EndIf ControlSetText($hWnd, "", $hCtrl, $sIconFolder) EndFunc Func _StopScript() $bRunning = False HotKeySet("{ESC}") HotKeySet("^!i") TraySetState($TRAY_ICONSTATE_HIDE) Exit EndFunc Edited Thursday at 06:46 PM by CodeHog WildByDesign 1
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