Jump to content

Set icon for specific filetype?


Rad
 Share

Recommended Posts

Im making a program b/c im building a new computer, so I built this little thing which shows all the primary things you need and a few optional things...I didnt want to save it as a .txt (and dont want to do registry keys or anything) so I made it save as a special file type, .cpf (ComPuter File)

Now it works and everything, theres one obvious problem.. the icon sucks! Its the standard white one which looks like a corrupted program, how can I set that type of file to a special icon (that I already made)?

Link to comment
Share on other sites

umm when u compile it u can select an icon if u use the compiler in the autoit folder.

--my 2 cents

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

  • Developers

WinXP:

Open Windows Explorer.

Select Tools/Folder options

Select tab FileTypes

Click New and type .CPF and click OK

Click Advanced and select alternative Icon

:lmao:

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

WinXP:

Open Windows Explorer.

Select Tools/Folder options

Select tab FileTypes

Click New and type .CPF and click OK

Click Advanced and select alternative Icon

:lmao:

it can also be done through the registry, but it's kind of a process. rather than explain it, i just added a 'change icon' to my right click menu editor. this may help you.

beta required, and in order to refresh the program (whenver changes are made, the gui hides itself, runs new instance, then closes old instance) you do have to run the script compiled.

Global $var2, $blah, $cmd, $ext
#NoTrayIcon
#include<GUIConstants.au3>
opt("GUIOnEventMode", 1)
$gui = GUICreate("Right Click", 500, 160)
$exts = GUICtrlCreateCombo("Extensions", 10, 10, 70, 25, $CBS_DROPDOWN)
$cmds = GUICtrlCreateCombo("Actions", 90, 10, 130, 25, $CBS_DROPDOWN)
$ct = GUICtrlCreateEdit("", 10, 45, 410, 30, BitOR($ES_AUTOHSCROLL, $ES_AUTOVSCROLL))
$eb = GUICtrlCreateButton("Edit", 10, 85, 50)
$sb = GUICtrlCreateButton("Save", 70, 85, 50)
$cb = GUICtrlCreateButton("Cancel", 130, 85, 50)
$na = GUICtrlCreateButton("New Action", 190, 85, 200)
$da = GUICtrlCreateButton("Delete Action", 230, 10)
$icon = GUICtrlCreateEdit("Icon", 320, 10, 100, -1, BitOR($ES_AUTOHSCROLL, $ES_AUTOVSCROLL))
$ci = GUICtrlCreateButton("Edit Icon", 430, 10, 60, 60)
ControlDisable("Right Click", "", $eb)
ControlDisable("Right Click", "", $ci)
ControlDisable("Right Click", "", $icon)
ControlDisable("Right Click", "", $na)
ControlDisable("Right Click", "", $sb)
ControlDisable("Right Click", "", $ct)
ControlDisable("Right Click", "", $cb)
ControlDisable("Right Click", "", $da)
ControlDisable("Right Click", "", $cmds)
GUICtrlSetOnEvent($exts, "EXTSelected")
GUICtrlSetOnEvent($cmds, "CMDSelected")
GUICtrlSetOnEvent($eb, "EditPushed")
GUICtrlSetOnEvent($sb, "SavePushed")
GUICtrlSetOnEvent($cb, "CancelPushed")
GUICtrlSetOnEvent($na, "NewSelected")
GUICtrlSetOnEvent($da, "DelSelected")
GUICtrlSetOnEvent($ci, "CISelected")
$i = 1
$cbt = ""
While 1
    $var = RegEnumKey("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\", $i)
    If $var = "" Then ExitLoop
    $cbt = $cbt & "|" & $var
    $i = $i + 1
WEnd
GUICtrlSetData($exts, $cbt)
ControlSetText("Right Click", "", $exts, "Extensions")
GUISetState()
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
While 1
    Sleep(100)
WEnd
Func CLOSEClicked()
    Exit
EndFunc  ;==>CLOSEClicked
Func EXTSelected()
    $acbt = ""
    $ext = GUICtrlRead($exts)
    $var2 = RegEnumVal("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $ext & "\OpenWithProgids", 1)
    $i = 1
    GUICtrlSetData($icon, RegRead("HKEY_CLASSES_ROOT\" & $var2 & "\DefaultIcon\", ""))
    While 1
        $var = RegEnumKey("HKEY_CLASSES_ROOT\" & $var2 & "\Shell\", $i)
        If $var = "" Then ExitLoop
        $acbt = $acbt & "|" & $var
        $i = $i + 1
    WEnd
    GUICtrlSetData($cmds, $acbt)
    ControlSetText("Right Click", "", $cmds, "Actions")
    ControlEnable("Right Click", "", $cmds)
    ControlEnable("Right Click", "", $ci)
    ControlEnable("Right Click", "", $na)
EndFunc  ;==>EXTSelected
Func CMDSelected()
    $cmd = GUICtrlRead($cmds)
    $blah = RegRead("HKEY_CLASSES_ROOT\" & $var2 & "\Shell\" & $cmd & "\Command\", "")
    GUICtrlSetData($ct, $blah)
    ControlEnable("Right Click", "", $eb)
    ControlEnable("Right Click", "", $da)
EndFunc  ;==>CMDSelected
Func EditPushed()
    ControlEnable("Right Click", "", $ct)
    ControlEnable("Right Click", "", $cb)
    ControlDisable("Right Click", "", $eb)
    ControlEnable("Right Click", "", $sb)
    ControlDisable("Right Click", "", $cmds)
    ControlDisable("Right Click", "", $exts)
EndFunc  ;==>EditPushed
Func SavePushed()
    $save = RegWrite("HKEY_CLASSES_ROOT\" & $var2 & "\Shell\" & $cmd & "\Command\", "", "REG_SZ", GUICtrlRead($ct))
    If $save Then
        MsgBox(0, "Success", "Registry updated.  Window must be refreshed")
        WinSetState("Right Click", "", @SW_HIDE)
        Run(@ScriptName)
        WinWaitActive("Right Click")
        Exit
    EndIf
EndFunc  ;==>SavePushed
Func CancelPushed()
    ControlSetText("Right Click", "", $ct, "")
    ControlEnable("Right Click", "", $cmds)
    ControlEnable("Right Click", "", $exts)
    ControlDisable("Right Click", "", $eb)
    ControlDisable("Right Click", "", $sb)
    ControlDisable("Right Click", "", $cb)
EndFunc  ;==>CancelPushed
Func NewSelected()
    $actionname = InputBox("New Action Name", "Enter a name for your new action to be added for files with the extension " & $ext)
    ControlSetText($gui, "", $cmds, $actionname)
    ControlEnable("Right Click", "", $ct)
    ControlEnable("Right Click", "", $cb)
    ControlEnable("Right Click", "", $sb)
    ControlDisable("Right Click", "", $na)
    $cmd = $actionname
EndFunc  ;==>NewSelected
Func DelSelected()
    $confirm = MsgBox(4, "Delete Action", "Are you sure you want to permanently delete the " & GUICtrlRead($cmds) & " action?")
    If $confirm = 6 Then
        $del = RegDelete("HKEY_CLASSES_ROOT\" & $var2 & "\Shell\" & $cmd)
        If $del Then
            MsgBox(0, "Action Deleted", "The " & $cmd & " action will no longer appear when you right click on " & GUICtrlRead($exts) & " files. The window must be refreshed")
            WinSetState("Right Click", "", @SW_HIDE)
            Run(@ScriptName)
            WinWaitActive("Right Click")
            Exit
        EndIf
    EndIf
EndFunc  ;==>DelSelected
Func CISelected()
    $newicon = FileOpenDialog("Choose new icon", "C:\", "All Files(*.*)")
    If Not @error Then
        $ni = RegWrite("HKEY_CLASSES_ROOT\" & $var2 & "\DefaultIcon\", "", "REG_SZ", $newicon)
        If $ni Then
            MsgBox(0, "Icon Changed", "The default icon for " & GUICtrlRead($exts) & " files has been changed. This window must be refreshed")
            WinSetState("Right Click", "", @SW_HIDE)
            Run(@ScriptName)
            WinWaitActive("Right Click")
            Exit
        EndIf
    EndIf
EndFunc
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...