#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=C:\Program Files (x86)\AutoIt3\Icons\au3.ico #AutoIt3Wrapper_Outfile_x64=enumicons.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Fileversion=2.1.0.4 #AutoIt3Wrapper_Res_ProductVersion=2.1.0.4 #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_Res_Field=Compiled with | AutoIt Version 3.3.18.0 #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer% #AutoIt3Wrapper_Res_Field=Compile date|%longdate% %time% #AutoIt3Wrapper_Run_After=del "%scriptfile%_stripped.au3" #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.18.0 Author: YDY (Lazycat) Modified: Jon, Jpm Script Function: Show all icons in the given file #ce ---------------------------------------------------------------------------- #Region ### Version History #cs ---------------------------------------------------------------------------- Version History 2.1.0.4 (2025/10/25) Updated: simplification by wakillon 2.1.0.0 (2021/12/06) Added: Scrollbar and optimisation of by name 2.0.1.0 (2007/11/14) Updated: simplification by Jon 2.0.0.0 (2007/08/02) Updated: use DllCallback.au3 1.0.0.0 (2006/06/20) Added: Initial version #ce ---------------------------------------------------------------------------- #EndRegion ### Version History #Region ;************ Includes ************ #include #include #include #include #Include #Include #Include #Include #EndRegion ;************ Includes ************ Opt('MustDeclareVars', 1) #Region ------ Global Variables ------------------------------ Global $sGuiTitle = 'Icon Selector by Name value - v2.1.0.4' Global $aIdIcons[30], $aIdLabels[30], $aIconsNames, $aCtrl, $aCtrlPos Global $hGui, $idButtonPrev, $idButtonNext, $idButtonFileSelect, $idButtonMode, $idComboDll Global $idLabelIconsCount, $iMsg, $idLabelPath, $idComboIconSize, $idCheckBkColor Global $sFilePath = @SystemDir & '\shell32.dll', $sNewFilePath, $sDefaultName, $sFullSavePath, $iDefaultSize, $sDefaultIndex Global $iStartIndex = 1, $bOrdinal = True, $iIconsCount #EndRegion --- Global Variables ------------------------------ _Gui() #Region ------ Main Loop ------------------------------ While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $idButtonFileSelect $sNewFilePath = FileOpenDialog('Select file:', @WorkingDir, 'File (*.exe;*.dll;*.ocx;*.icl;*.ico)', 0, '', $hGui) If @error Then ContinueLoop If $sNewFilePath <> $sFilePath Then $iStartIndex = 1 $sFilePath = $sNewFilePath GUICtrlSetData($idLabelPath, _WinAPI_PathCompactPath($hGui, $sFilePath, 440)) $iIconsCount = _IconsGetCount($sFilePath) GUICtrlSetData($idLabelIconsCount, $iIconsCount & ' icons') If $iIconsCount < UBound($aIdIcons) +1 Then GUICtrlSetState($idButtonNext, $GUI_DISABLE) GUICtrlSetState($idButtonPrev, $GUI_DISABLE) Else GUICtrlSetState($idButtonNext, $GUI_ENABLE) EndIf $aIconsNames = _WinAPI_EnumResourceNames($sFilePath, $RT_GROUP_ICON) _GuiUpdate() EndIf Case $idButtonPrev $iStartIndex -= UBound($aIdIcons) _GuiUpdate() Case $idButtonNext $iStartIndex += UBound($aIdIcons) _GuiUpdate() Case $idButtonMode If $bOrdinal = False Then $bOrdinal = True GUICtrlSetData($iMsg, 'by Name') WinSetTitle($hGui, '', $sGuiTitle) If $iStartIndex > $iIconsCount Then $iStartIndex = 1 Else $bOrdinal = False GUICtrlSetData($iMsg, 'by Ordinal') WinSetTitle($hGui, '', $sGuiTitle) If $iStartIndex > $iIconsCount Then $iStartIndex = 1 EndIf _GuiUpdate() Case $idComboDll $sNewFilePath = @SystemDir & '\' & GUICtrlRead($iMsg) If $sNewFilePath <> $sFilePath Then $iStartIndex = 1 $sFilePath = $sNewFilePath GUICtrlSetData($idLabelPath, _WinAPI_PathCompactPath($hGui, $sFilePath, 440)) $iIconsCount = _IconsGetCount($sFilePath) GUICtrlSetData($idLabelIconsCount, $iIconsCount & ' icons') If $iIconsCount < 31 Then GUICtrlSetState($idButtonNext, $GUI_DISABLE) GUICtrlSetState($idButtonPrev, $GUI_DISABLE) Else GUICtrlSetState($idButtonNext, $GUI_ENABLE) EndIf $aIconsNames = _WinAPI_EnumResourceNames($sFilePath, $RT_GROUP_ICON) _GuiUpdate() EndIf Case $GUI_EVENT_DROPPED $sNewFilePath = @GUI_DragFile If $sNewFilePath <> $sFilePath Then $iStartIndex = 1 $sFilePath = $sNewFilePath GUICtrlSetData($idLabelPath, _WinAPI_PathCompactPath($hGui, $sFilePath, 440)) $iIconsCount = _IconsGetCount($sFilePath) GUICtrlSetData($idLabelIconsCount, $iIconsCount & ' icons') If $iIconsCount < UBound($aIdIcons) +1 Then GUICtrlSetState($idButtonNext, $GUI_DISABLE) GUICtrlSetState($idButtonPrev, $GUI_DISABLE) Else GUICtrlSetState($idButtonNext, $GUI_ENABLE) EndIf $aIconsNames = _WinAPI_EnumResourceNames($sFilePath, $RT_GROUP_ICON) _GuiUpdate() EndIf Case $GUI_EVENT_CLOSE Exit Case $aIdIcons[0] To $aIdIcons[29] +1 $aCtrl = GUIGetCursorInfo($hGui) If Not @error Then If Mod($aCtrl[4],2) Then $aCtrl[4] = $aCtrl[4] -1 GUICtrlSetState($aCtrl[4], $GUI_CHECKED) EndIf $iDefaultSize = GUICtrlRead($idComboIconSize) $aCtrlPos = ControlGetPos($hGui, '', $aCtrl[4]) Sleep(500) $sDefaultName = StringReplace(_FileGetName($sFilePath), '.', '') $sDefaultIndex = $iStartIndex+($aCtrl[4]/2) -6 If $bOrdinal = True Then $sDefaultName &= '.' & StringFormat('%04i', StringReplace($sDefaultIndex, '"', '' )) & '-' & $iDefaultSize & 'x' & $iDefaultSize & '.ico' Else If IsNumber($aIconsNames[$sDefaultIndex]) Then $sDefaultName &= '.' & StringFormat('%04i', $aIconsNames[$sDefaultIndex]) & '-' & $iDefaultSize & 'x' & $iDefaultSize & '.ico' Else $sDefaultName &= '.' & StringReplace($aIconsNames[$sDefaultIndex], '"', '' ) & '-' & $iDefaultSize & 'x' & $iDefaultSize & '.ico' EndIf EndIf $sFullSavePath = FileSaveDialog('Save Icon', @WorkingDir, '(*.ico)', 2+16, $sDefaultName, $hGui) If Not @error Then _IconSaveFromFile($sFilePath, $sDefaultIndex -2, $sFullSavePath, $iDefaultSize) If @error Then MsgBox(262144+16, 'Error _IconSaveFromFile', 'Sorry an error ' & @error & ' occurred when saving icon', 5 ) EndIf GUICtrlSetState($aCtrl[4], $GUI_UNCHECKED) EndIf Case $idCheckBkColor If BitAND(GUICtrlRead($iMsg), $GUI_CHECKED) = $GUI_CHECKED Then _WinAPI_SetThemeAppProperties($STAP_ALLOW_NONCLIENT) Else _WinAPI_SetThemeAppProperties($STAP_ALLOW_CONTROLS) EndIf For $i = 0 To UBound($aIdIcons) -1 GUICtrlSendMsg($aIdIcons[$i], $WM_THEMECHANGED, 0, 0) Next EndSwitch Sleep(10) WEnd #EndRegion --- Main Loop ------------------------------ Func _FileGetName($sFilePath) Local $aFileName = StringSplit($sFilePath, '\') If Not @error Then Return $aFileName[$aFileName[0]] Return $sFilePath EndFunc ;==> _FileGetName() Func _Gui() $hGui = GUICreate($sGuiTitle, 395, 465, @DesktopWidth/2 -192, @DesktopHeight/2 -235, $GUI_SS_DEFAULT_GUI, $WS_EX_ACCEPTFILES) GUICtrlCreateGroup('', 5, 1, 385, 40) GUICtrlCreateGroup('', 5, 50, 385, 380) $idComboDll = GUICtrlCreateCombo('shell32.dll', 12, 14, 112, 16) Local $sDllString = 'user32.dll|imageres.dll|netshell.dll|wmploc.dll|ddores.dll|mmcndmgr.dll|moricons.dll|ieframe.dll|compstui.dll|' & _ 'setupapi.dll|synccenter.dll|pifmgr.dll|dsuiext.dll|msihnd.dll|stobject.dll|rasgcw.dll|msctf.dll|mshtml.dll|msutb.dll|cryptui.dll|' & _ 'wiashext.dll|twinui.dll|rasdlg.dll|accessibilitycpl.dll|wpdshext.dll|sensorscpl.dll|ipsmsnap.dll|networkexplorer.dll|comres.dll|' & _ 'comdlg32.dll' Local $aDllString = StringSplit($sDllString, '|') For $i = 1 To UBound( $aDllString ) -1 If Not FileExists(@SystemDir & '\' & $aDllString[$i]) Then $sDllString = StringReplace($sDllString, $aDllString[$i], '' ); remove dll not existing Next GUICtrlSetData($idComboDll, $sDllString, 'shell32.dll') $iIconsCount = _IconsGetCount($sFilePath) $idLabelIconsCount = GUICtrlCreateLabel($iIconsCount & ' icons', 215, 19, 50, 16) GUICtrlSetColor(-1, 0xFF0000) $idButtonFileSelect = GUICtrlCreateButton('...', 347, 12, 36, 24) GUICtrlSetFont(-1, 18) GUICtrlSetTip(-1, 'or Click for Select ', 'Drag a file', 1, 1) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $idButtonPrev = GUICtrlCreateButton('Previous', 10, 45, 60, 24, $BS_FLAT) GUICtrlSetState(-1, $GUI_DISABLE) $idButtonNext = GUICtrlCreateButton('Next', 75, 45, 60, 24, $BS_FLAT) $idButtonMode = GUICtrlCreateButton('by Name', 300, 45, 60, 24, $BS_FLAT) GUICtrlCreateLabel('Size', 270, 18, 25, 16) Local $iCurrentIndex $aIconsNames = _WinAPI_EnumResourceNames($sFilePath, $RT_GROUP_ICON) For $iRowCount = 0 To 4 For $iColomnCount = 0 To 5 $iCurrentIndex = $iRowCount*6 + $iColomnCount $aIdIcons[$iCurrentIndex] = GUICtrlCreateRadio('', 60*$iColomnCount +25, 70*$iRowCount +80, 48, 48, BitOR($BS_ICON, $BS_PUSHLIKE, $BS_FLAT, $BS_CENTER)) GUICtrlSetImage(-1, $sFilePath, -($iCurrentIndex +1), 1) $aIdLabels[$iCurrentIndex] = GUICtrlCreateLabel(-($iCurrentIndex +1), 60*$iColomnCount +17, 70*$iRowCount +129, 60, 16, $SS_CENTER) Next Next $idComboIconSize = GUICtrlCreateCombo('32', 297, 14, 43, 16) GUICtrlSetData($idComboIconSize, '16|32|48|64|128', '32') GUICtrlSetTip(-1, 'when saving icon', 'Size used', 1, 1) $idCheckBkColor = GUICtrlCreateCheckbox('BkColor', 140, 18, 58, 16) GUICtrlSetTip(-1, 'Background Color', "Change Icon's", 1, 1) GUICtrlCreateGroup('', 5, 430, 385, 30) $idLabelPath = GUICtrlCreateLabel($sFilePath, 10, 440, 375, 16) GUICtrlSetColor(-1, 0x0094FF) GUISetState() EndFunc ;==> _Gui() Func _GuiUpdate() GUISetState(@SW_DISABLE , $hGui) If $iIconsCount - $iStartIndex < UBound($aIdIcons) Then GUICtrlSetState($idButtonNext, $GUI_DISABLE) For $i = UBound($aIdIcons) -1 To $iIconsCount -$iStartIndex Step -1 If $i < 0 Then ExitLoop GUICtrlSetState($aIdIcons[$i], $GUI_HIDE) GUICtrlSetState($aIdIcons[$i], $GUI_DISABLE) GUICtrlSetData($aIdLabels[$i], '') GUICtrlSetState($aIdLabels[$i], $GUI_DISABLE) Next Else GUICtrlSetState($idButtonNext, $GUI_ENABLE) EndIf If $iIconsCount Then Local $j = 0 For $i = $iStartIndex To $iStartIndex +UBound($aIdIcons) -1 GUICtrlSetState($aIdIcons[$j], $GUI_SHOW) GUICtrlSetState($aIdIcons[$j], $GUI_ENABLE) GUICtrlSetImage($aIdIcons[$j], $sFilePath, -$i) If Not $bOrdinal Then If IsNumber($aIconsNames[$iStartIndex +$j]) Then GUICtrlSetFont($aIdLabels[$j], 8.5) GUICtrlSetTip( $aIdLabels[$j], '') Else If StringLen($aIconsNames[$iStartIndex +$j]) > 1 Then GUICtrlSetFont($aIdLabels[$j], 6) GUICtrlSetTip($aIdLabels[$j], $aIconsNames[$iStartIndex +$j], 'Icon Name', 1, 1) EndIf EndIf GUICtrlSetData($aIdLabels[$j], '"' & $aIconsNames[$iStartIndex +$j] & '"') GUICtrlSetState($aIdLabels[$j], $GUI_ENABLE) Else GUICtrlSetData($aIdLabels[$j], -($iStartIndex +$j)) GUICtrlSetFont($aIdLabels[$j], 8.5) GUICtrlSetTip($aIdLabels[$j], '') GUICtrlSetState($aIdLabels[$j], $GUI_ENABLE) EndIf $j+=1 If $j > $iIconsCount -$iStartIndex Then ExitLoop Next EndIf If $iStartIndex = 1 Then GUICtrlSetState($idButtonPrev, $GUI_DISABLE) Else GUICtrlSetState($idButtonPrev, $GUI_ENABLE) EndIf GUISetState(@SW_ENABLE , $hGui) EndFunc ;==> _GuiUpdate() Func _IconSaveFromFile($sPath, $iIndex, $sIconSavePath, $iIconSize=32) Local $iTotal = _WinAPI_ExtractIconEx($sPath, -1, 0, 0, 0) If @error Or Abs($iIndex+1) > $iTotal Then Return SetError(1) $iIndex = Abs($iIndex+1) Local $hIco = _WinAPI_ShellExtractIcon($sPath, $iIndex, $iIconSize, $iIconSize) If @error Or Not $hIco Then Return SetError(2) Local $hIcon = _WinAPI_Create32BitHICON($hIco, False) If @error Then Return SetError(3) _WinAPI_SaveHICONToFile($sIconSavePath, $hIcon, 0, 0, -1) If @error Then Return SetError(4) If $hIco Then _WinAPI_DestroyIcon($hIco) If $hIcon Then _WinAPI_DestroyIcon($hIcon) Return FileExists($sIconSavePath) EndFunc ;==> _IconSaveFromFile() Func _IconsGetCount($sFilePath) Local $aRet = DllCall('shell32.dll', 'uint', 'ExtractIconExW', 'wstr', $sFilePath, 'int', -1, 'struct*', 0, 'struct*', 0, 'uint', 0) If @error Then Return SetError(@error, @extended, 0) Local $hIcoTest ; Remove empty icons (or false icons) from count For $i = -$aRet[0] To -1 Step 1 $hIcoTest = _WinAPI_ShellExtractIcon($sFilePath, Abs($i+1), 32, 32) If @error Or Not $hIcoTest Then $aRet[0] -=1 If $hIcoTest Then _WinAPI_DestroyIcon($hIcoTest) Next Return $aRet[0] EndFunc ;==> _IconsGetCount()()