Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; <COMPILER: v1.1.32.00>
- ;#Warn
- #NoEnv
- #SingleInstance, Force
- SendMode Input
- SetWorkingDir %A_ScriptDir%
- /*
- Description:
- Do you know Microangelo?
- This program is an Icon manager. With it you can change any icon for a file
- type in a very simple way.
- Folder icon can be changed. You can change the icon for each folder separatly too.
- There is also a support for themes, but differently from other softwares,
- in this program a theme is a folder containing some icons.
- The name of the icon is the file type to wich the icon will be associated.
- For example an icon named mp3.ico will cause all mp3 files to be shown with
- that icon.
- Version:
- 0.5.2 beta
- License:
- GPL
- Note:
- This is a beta version. Use it at your own risk
- ToDo:
- 1)Drag&Drop support to drop an icon file to the program window
- 2)Support for special folders like My computer or Desktop
- 3)Support for themes where a theme is a single zip file
- 4)Define special names in a theme like "folder.ico" for the folder icon
- 5)Documentation
- 6)Rebuild icon cache:
- Just refresh the icon cache by deleting the IconCache.db
- file from your profile directory (usually /Documents and
- Settings/Username/Local Settings/Application Data). It
- will be automatically recreated.
- Bugs:
- ?
- History:
- 24/04/2006 - added support to restore original icons
- */
- #SingleInstance force
- #NoTrayIcon
- SetBatchLines -1
- ScanStatus := False
- If ( A_OSType = "WIN32_WINDOWS" ) ; Windows 9x
- ScanFolder = %A_WinDir%\system
- else
- ScanFolder = %A_WinDir%\system32
- Gui, Add, Text, Section , Scan folder
- Gui, Add, Edit, ys-3 w245 r1 vScanFolder, %ScanFolder%
- Gui, Add, Button, ys-5 gBtnBrowseFolder,&...
- Gui, Add, Button, ys-5 w50 vBtnScan gBtnScan, &Scan
- Gui, Add, Checkbox, ys vCkbRecursive , Rec&ursive
- Gui, Add, ListView, xm r11 w480 -Multi AltSubmit List vLstOfFiles gLstOfFiles ,Icon Nr.1 & File name|Path
- Gui, Add, Text, w140 vTxtFilesFound Section, 0000 files found, shown as
- Gui, Add, Radio, ys gRadFilesReport ,&Report
- Gui, Add, Radio, ys gRadFilesTile , &Tile
- Gui, Add, Radio, ys gRadFilesIcons , &Icons
- Gui, Add, Radio, ys gRadFilesSmallIcons ,s&mall Icons
- Gui, Add, Radio, ys Checked gRadFilesList , &List
- Gui, Add, ListView, xm r2 w480 -Multi AltSubmit Icon vLstOfIcons gLstOfIcons,Icon
- Gui, Add, Text, w140 vTxtIconsFound Section, 0000 Icons found, shown as
- Gui, Add, Radio, ys gRadIconsReport ,Report
- Gui, Add, Radio, ys gRadIconsTile ,Til&e
- Gui, Add, Radio, ys Checked gRadIconsIcons , Ic&ons
- Gui, Add, Radio, ys gRadIconsSmallIcons ,sm&all Icons
- Gui, Add, Radio, ys gRadIconsList , List
- Gui,add,Text, xm ys+40 Section, Select a file type
- Gui,add,Edit, x+2 ys-3 vext gExtension
- Gui,add,Text, x+2 , or:
- Gui,add,button,x+20 gBtnASITSF, Apply Selected Icon to a specified Folder
- Gui,add,button,x+5 gBtnSpecialIcons, Special Icons
- Gui,add,Text, xm , from
- Gui,add,Picture, x+20 vActualIcon Icon1 w32 h-1 , %ScanFolder%\shell32.dll
- Gui,add,Text, x+20 , to
- Gui,add,Picture, x+20 vNewIcon Icon1 w32 h-1 , %ScanFolder%\shell32.dll
- Gui,add,Text, x+20 , ...
- Gui,add,button,x+20 gBtnSet vBtnSet , Set
- Gui,add,Text, x+20 , Original Icon:
- Gui,add,Picture, x+20 vfirstIcon Icon1 w32 h-1 , %ScanFolder%\shell32.dll
- Gui,add,button,x+20 gBtnRestore vBtnRestore , Restore
- Gui, Add, Button, xm vBtnSpecialActions gBtnSpecialActions Section ,Special Action
- Gui, Add, Button, ys gBtnClose,&Close
- Gui, Show, , Icon Viewer v5
- Return
- ;############# End of autoexec section ####################################
- BtnSpecialActions:
- Menu,sf,add
- Menu,sf,deleteall
- Menu,sf,add,Set a theme, saction
- Menu,sf,add,Refresh icon cache(beta), saction
- Menu,sf,show
- return
- saction:
- if(A_ThisMenuItemPos=1)
- {
- FileSelectFolder, fold, , , Select the folder containg all the icons. N.B.: A theme is a folder containing several icons whose name is the file type for that icon. Ex: "gif.ico" will set gif files
- if(fold="")
- return
- Loop,%fold%\*.ico
- {
- StringTrimRight, ext, A_LoopFileName, 4
- RegRead, from, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer \FileExts\.%ext%, ProgID
- if(from="")
- RegRead, from, HKEY_CLASSES_ROOT, .%ext%
- RegWrite, REG_SZ, HKEY_CLASSES_ROOT, %from%\DefaultIcon, , %fold%\%ext%.ico
- }
- fold=
- }
- else if(A_ThisMenuItemPos=2)
- {
- SplitPath, A_WinDir, , , , , OutDrive
- file=%OutDrive%/Documents and Settings/ %A_UserName%/Local Settings/Application Data/IconCache.db
- FileDelete, %file%
- }
- return
- BtnASITSF:
- FileSelectFolder, dir, , , Select a folder to apply this icon to it
- n2=0
- IfInString, newIconFile, `,
- {
- StringSplit, n, newIconFile, `,
- trim:=StrLen(n2)+1
- StringTrimRight, newIconFile, newIconFile, %trim%
- }
- FileDelete, %dir%\desktop.ini
- FileAppend,
- (
- [.ShellClassInfo]
- IconFile=%newIconFile%
- IconIndex=%n2%
- )`n, %dir%\Desktop.ini
- Sleep,100
- FileSetAttrib, +ASH, %dir%\Desktop.ini
- FileSetAttrib, +S, %dir%
- return
- BtnSpecialIcons:
- Menu,sf,add
- Menu,sf,deleteall
- Menu,sf,add,Folder Icon, sicons
- Menu,sf,add,My computer Icon, sicons
- Menu,sf,add,Empty Recycle Bin Icon, sicons
- Menu,sf,add,Full Recycle Bin Icon, sicons
- Menu,sf,add,Desktop Icon, sicons
- Menu,sf,show
- return
- sicons:
- if(A_ThisMenuItemPos=1)
- {
- from=Folder
- RegRead, ico, HKEY_CLASSES_ROOT, %from%\DefaultIcon
- }
- else
- msgbox,not yet implemented
- if (A_ThisMenuItemPos=2)
- {
- from={20D04FE0-3AEA-1069-A2D8- 08002B30309D}
- RegRead, ico, HKEY_LOCAL_MACHINE, SOFTWARE\Classes\CLSID\%from%\DefaultIcon
- }
- else if (A_ThisMenuItemPos=3)
- {
- from={645FF040-5081-101B-9F08- 00AA002F954E}
- RegRead, ico, HKEY_LOCAL_MACHINE, SOFTWARE\Classes\CLSID\%from%\DefaultIcon
- }
- else if (A_ThisMenuItemPos=4)
- {
- from={645FF040-5081-101B-9F08- 00AA002F954E}
- RegRead, ico, HKEY_LOCAL_MACHINE, SOFTWARE\Classes\CLSID\%from%\DefaultIcon,Full
- }
- IfInString, ico, `,
- {
- StringSplit, n, ico, `,
- n2++
- trim:=StrLen(n2)+1
- StringTrimRight, ico, ico, %trim%
- }
- GuiControl,,actualIcon, *icon%n2% *w32 *h-1 %ico%
- return
- Extension:
- Gui, Submit, nohide
- IniRead, orIcon, conf.ini, originalIcons, %ext%
- RegRead, from, HKEY_CURRENT_USER, Software\Microsoft \Windows\CurrentVersion\Explorer\FileExts\.%ext%, ProgID
- if(from="")
- RegRead, from, HKEY_CLASSES_ROOT, .%ext%
- RegRead, ico, HKEY_CLASSES_ROOT, %from%\DefaultIcon
- if(orIcon="")
- orIcon=%ico%
- originalIcon=%ico%
- IfInString, ico, `,
- {
- StringSplit, n, ico, `,
- trim:=StrLen(n2)+1
- StringTrimRight, ico, ico, %trim%
- }
- IfInString, orIcon, `,
- {
- StringSplit, on, orIcon, `,
- trim:=StrLen(on2)+1
- StringTrimRight, orIcon, orIcon, %trim%
- }
- GuiControl,,firstIcon, *icon%on2% *w32 *h-1 %orIcon%
- GuiControl,,actualIcon, *icon%n2% *w32 *h-1 %ico%
- return
- BtnSet:
- if(newIconFile="")
- return
- IniWrite, %originalIcon%, conf.ini, originalIcons, %ext%
- RegWrite, REG_SZ, HKEY_CLASSES_ROOT, %from%\DefaultIcon, , %newIconFile%
- return
- BtnRestore:
- Gui, Submit, nohide
- RegRead, from, HKEY_CURRENT_USER, Software\Microsoft \Windows\CurrentVersion\Explorer\FileExts\.%ext%, ProgID
- if(from="")
- RegRead, from, HKEY_CLASSES_ROOT, .%ext%
- RegWrite, REG_SZ, HKEY_CLASSES_ROOT, %from%\DefaultIcon, , %orIcon%
- return
- ;############# Browse to the folder from where the serach should start ####
- BtnBrowseFolder:
- Gui, +OwnDialogs
- FileSelectFolder, SelectedDir, *%ScanFolder%, 2, Select folder to start searching for icons
- If SelectedDir
- {
- ;remove "\" if folder is a root drive, e.g. "C:\"
- StringRight, LastChar, SelectedDir, 1
- If LastChar = \
- StringTrimRight, SelectedDir, SelectedDir, 1
- GuiControl, ,ScanFolder, %SelectedDir%
- }
- Gosub, BtnScan
- Return
- ;############# Start or stop scanning for files ###########################
- BtnScan:
- If ScanStatus
- ;break scan loop
- ScanStatus := False
- Else
- ;start a new thread for scaning
- SetTimer, Scan, 20
- return
- ;############# Scan the folder for files with icons #######################
- Scan:
- SetTimer, Scan, Off
- ScanStatus := True
- Gui, Submit, NoHide
- ;change lable and make default button: scan/stop
- GuiControl, , BtnScan, &STOP
- GuiControl, +Default, BtnScan
- ;disable redraw for speed
- GuiControl, -Redraw, LstOfFiles
- ;set list of files as default
- Gui, ListView, LstOfFiles
- ;clear list of files
- LV_Delete()
- ;create new list of small images and replace and delete old one
- IListIDFilesSmall := IL_Create(100, 100, False)
- ListID := LV_SetImageList(IListIDFilesSmall)
- If ListID
- IL_Destroy(ListID)
- ;create new list of large images and replace and delete old one
- IListIDFilesLarge := IL_Create(100, 100, True)
- ListID := LV_SetImageList(IListIDFilesLarge)
- If ListID
- IL_Destroy(ListID)
- ;Search all files
- i = 0
- Loop, %ScanFolder%\*, 0, %CkbRecursive%
- {
- ;If their extention is exe,dll,ico,ani,cpl ...
- If A_LoopFileExt Contains exe,dll,ico,ani,cpl
- {
- ;... get first icon (small) ...
- ID := IL_Add(IListIDFilesSmall, A_LoopFileFullPath, 1)
- ;... And If they have a first Icon ...
- If ID > 0
- {
- ;get large icon
- IL_Add(IListIDFilesLarge, A_LoopFileFullPath, 1)
- ;count this file
- i++
- ;add file to ListView
- LV_Add("Icon" . i, A_LoopFileName, A_LoopFileDir)
- GuiControl,,TxtFilesFound,%i% files found, shown as
- }
- }
- ;break loop if user pushes STOP button
- If not ScanStatus
- break
- }
- ScanStatus := False
- ;Enable redraw for speed
- GuiControl, +Redraw, LstOfFiles
- ;Adjust width
- LV_ModifyCol()
- ;rename button to scan again
- GuiControl, , BtnScan, &Scan
- Return
- ;############# A file got selelected in list ##############################
- LstOfFiles:
- ;file is selected with mouse or by keyboard
- If ( A_GuiEvent = "I" )
- {
- ;set list of files as default
- Gui, ListView, LstOfFiles
- ;get selected file
- RowNumber := LV_GetNext()
- LV_GetText(IV_File, RowNumber, 1)
- LV_GetText(IV_Path, RowNumber, 2)
- ;set list of icons as default
- Gui, ListView, LstOfIcons
- ;diable redraw for speed
- GuiControl, -Redraw, LstOfIcons
- ;clear list
- LV_Delete()
- ;create new list of small images and replace and delete old one
- IListIDIconsSmall := IL_Create(10, 10, False)
- ListID := LV_SetImageList(IListIDIconsSmall)
- If ListID
- IL_Destroy(ListID)
- ;create new list of large images and replace and delete old one
- IListIDIconsLarge := IL_Create(10, 10, True)
- ListID := LV_SetImageList(IListIDIconsLarge)
- If ListID
- IL_Destroy(ListID)
- i = 0
- ;Search for 9999 icons in the selected file
- Loop, 9999
- {
- ;get small icon
- ID := IL_Add(IListIDIconsSmall, IV_Path . "\" . IV_File , A_Index)
- ;if small icon exist
- If ID > 0
- {
- ;get large icon
- IL_Add(IListIDIconsLarge, IV_Path . "\" . IV_File , A_Index)
- i++
- ;add icon to list
- LV_Add("Icon" . A_Index, A_Index)
- GuiControl,,TxtIconsFound,%i% icons found, shown as
- }
- Else
- Break
- }
- ;enable redraw for speed
- GuiControl, +Redraw, LstOfIcons
- ;clear edit field
- GuiControl,,AHKCommand,
- }
- Return
- ;############# Change of view mode for file list ##########################
- RadFilesReport:
- GuiControl, +Report, LstOfFiles
- Gui, ListView, LstOfFiles
- LV_ModifyCol()
- Return
- RadFilesTile:
- GuiControl, +Tile, LstOfFiles
- Return
- RadFilesIcons:
- GuiControl, +Icon, LstOfFiles
- Return
- RadFilesSmallIcons:
- GuiControl, +IconSmall, LstOfFiles
- Return
- RadFilesList:
- GuiControl, +List, LstOfFiles
- Return
- ;############# A icon got selected in list ################################
- LstOfIcons:
- ;icon is selected with mouse or by keyboard
- If ( A_GuiEvent = "I" )
- GoSub, RadAHKCommand
- return
- ;############# AHK command got changed ####################################
- RadAHKCommand:
- ;set list of icons as default
- Gui, ListView, LstOfIcons
- ;get selected
- RowNumber := LV_GetNext()
- ;If something is selected (might not be true if RadAHKCommand is calling)
- If RowNumber
- {
- ;get Icon number
- LV_GetText(IV_IconID, RowNumber, 1)
- ;get AHKCommand
- Gui, Submit, NoHide
- GuiControl,, newIcon, *icon%IV_IconID% *w32 *h-1 %IV_Path%\%IV_File%
- ;GuiControl,,AHKCommand, icon%IV_IconID% ,
- newIconFile=%IV_Path%\%IV_File%
- icgroup=exe,dll
- SplitPath, newIconFile, , , OutExtension
- IfInString, icgroup, %OutExtension%
- {
- IV_IconID--
- newIconFile=%newIconFile%, %IV_IconID%
- }
- }
- Return
- ;############# Change of view mode for icon list ##########################
- RadIconsReport:
- GuiControl, +Report, LstOfIcons
- Gui, ListView, LstOfIcons
- LV_ModifyCol()
- Return
- RadIconsTile:
- GuiControl, +Tile, LstOfIcons
- Return
- RadIconsIcons:
- GuiControl, +Icon, LstOfIcons
- Return
- RadIconsSmallIcons:
- GuiControl, +IconSmall, LstOfIcons
- Return
- RadIconsList:
- GuiControl, +List, LstOfIcons
- Return
- ;############# Close window ###############################################
- BtnClose:
- GuiClose:
- GuiEscape:
- ExitApp
- Return
- ;############# End of File ################################################
- ;==========================
- #R::Reload ;<-- ~ Reload Script ~
- #S::Suspend ;<-- ~ Suspend Script ~
- #P::Pause ;<-- ~ Pause Script ~
- #M::WinMinimize, ;<-- ~ Minimize Script ~
- ESC::ExitApp ;<-- ~ Exit Script ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement