#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=icon.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;~ #RequireAdmin #include #include #include Opt('TrayMenuMode', 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode. Local $website = TrayCreateItem('Created by: TheAutomator') ; ARGUMENTS: 0 = count, 1 = option:drive|folder, 2 = path, 3 = icon Const Enum $ArgCnt, $ArgOpt, $ArgDir, $ArgIco If $cmdline[$ArgCnt] <> 3 Then ReDim $cmdline[4] If StringRegExp($cmdline[$ArgOpt], '(?i)^(drive|folder)$') = 0 Then ShellExecute('https://iconarchive.com/') Exit EndIf If $cmdline[$ArgDir] = '' Then $cmdline[$ArgDir] = FileSelectFolder('Select ' & $cmdline[$ArgOpt] & ' To Iconize', '', 0) If @error Then Exit EndIf If (FileExists($cmdline[$ArgDir]) And StringInStr(FileGetAttrib($cmdline[$ArgDir]),'D')) = False Then Exit $ArgDir If StringRight($cmdline[$ArgDir], 1) = '\' Then $cmdline[$ArgDir] = StringTrimRight($cmdline[$ArgDir], 1) ; when a drive is selected If $cmdline[$ArgIco] = '' Then ;~ Local $Icon = _WinAPI_PickIconDlg($DefIco) ; returns $array[2] : 0 = icon path, 1 = icon index $cmdline[$ArgIco] = FileOpenDialog('Select Icon For: ' & $cmdline[$ArgDir], @ScriptDir & '\Icons', 'Icon Files (*.ico)', 3) If @error Then Exit EndIf If FileExists($cmdline[$ArgIco]) = False Then Exit $ArgIco If FileExists($cmdline[$ArgDir] & '\Iconized.ico') Then FileSetAttrib($cmdline[$ArgDir] & '\Iconized.ico', '-R') ; remove readonly to allow overwrite FileCopy($cmdline[$ArgIco], $cmdline[$ArgDir] & '\Iconized.ico', 1) FileSetAttrib($cmdline[$ArgDir] & '\Iconized.ico', '+HR') ; hidden + readonly If $cmdline[$ArgOpt] = 'folder' Then If FileExists($cmdline[$ArgDir] & '\Desktop.ini') Then FileSetAttrib($cmdline[$ArgDir] & '\Desktop.ini', '-R') ; remove readonly to allow overwrite ; Create struct to apply icon Local $tSHFCS = DllStructCreate($tagSHFOLDERCUSTOMSETTINGS & ';wchar szIconFile[' & 13 & ']') DllStructSetData($tSHFCS, 'Size', DllStructGetPtr($tSHFCS, 'szIconFile') - DllStructGetPtr($tSHFCS)) DllStructSetData($tSHFCS, 'Mask', $FCSM_ICONFILE) DllStructSetData($tSHFCS, 'IconFile', DllStructGetPtr($tSHFCS, 'szIconFile')) DllStructSetData($tSHFCS, 'SizeIF', 260) DllStructSetData($tSHFCS, 'IconIndex', 0) DllStructSetData($tSHFCS, 'szIconFile', 'Iconized.ico') ; Set icon to selected folder _WinAPI_ShellGetSetFolderCustomSettings($cmdline[$ArgDir], $FCS_FORCEWRITE, $tSHFCS) FileSetAttrib($cmdline[$ArgDir] & '\Desktop.ini','+RSH') Else If FileExists($cmdline[$ArgDir] & '\Autorun.inf') Then FileSetAttrib($cmdline[$ArgDir] & '\Autorun.inf', '-R') ; remove readonly to allow overwrite IniWrite($cmdline[$ArgDir] & '\Autorun.inf', 'Autorun', 'Icon', 'Iconized.ico') FileSetAttrib($cmdline[$ArgDir] & '\Autorun.inf','+RSH') EndIf DllCall('shell32.dll', 'none', 'SHChangeNotify', 'long', 0x08000000, 'uint', 0, 'ptr', 0, 'ptr', 0) ; refresh icons (sometimes needed if winapi doesn't do the trick?)