gaxar77 Posted September 30, 2019 Share Posted September 30, 2019 (edited) This is a simple application I wrote that let's you modify the new file context menu. You can add and remove file types based on their extension. It shows a list of all the file types that are in the new menu based on their extension, and you can add and remove file types. expandcollapse popup; Windows New File Context Menu Editor ; Author: gaxar77 #include "GuiConstants.au3" #include "GuiListBox.au3" Func _RegExistKey($sKeyname) RegEnumVal ($sKeyname, 1) Return (@error <= 0) EndFunc Func ShellNewKeyName($ext) Return "HKEY_CLASSES_ROOT\" & $ext & "\ShellNew" EndFunc Func MsgBoxCannotModifyRegistry() MsgBox(0, "Error", "Unable to modify registry.") EndFunc $gui = GUICreate("Windows New File Context Menu Editor", 465, 445) GuiSetState(@SW_SHOW, $gui) $fileTypesList = GUICtrlCreateList("", 10, 10, 400, 400) $newFileTypeTextBox = GuiCtrlCreateInput("", 10, 415, 350, 20) $newFileTypeButton = GuiCtrlCreateButton("Add", 365, 415, 45, 20) $removeFileTypeButton = GuiCtrlCreateButton("Remove", 415, 10, 45, 20) $keyIndex = 1 While True $keyName = RegEnumKey("HKEY_CLASSES_ROOT", $keyIndex) If @error <> 0 Then ExitLoop EndIf If StringLeft($keyName, 1) = "." Then If _RegExistKey(ShellNewKeyName($keyName)) Then _GuiCtrlListBox_AddString($fileTypesList, $keyName) EndIf EndIf $keyIndex += 1 WEnd While True $msg = GuiGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $newFileTypeButton $ext = GuiCtrlRead($newFileTypeTextBox) If StringLen($ext) < 2 or StringLeft($ext, 1) <> "." Then MsgBox(0, "Error", "Invalid Extension") Else $newKeyName = ShellNewKeyName($ext) RegWrite($newKeyName) RegWrite($newKeyName, "NullFile", "REG_SZ", "") If _RegExistKey($newKeyName) Then If _GuiCtrlListBox_FindString($fileTypesList, $ext) = -1 Then _GuiCtrlListBox_AddString($fileTypesList, $ext) EndIf Else MsgBoxCannotModifyRegistry() EndIf EndIf Case $removeFileTypeButton $ext = GuiCtrlRead($fileTypesList) If $ext <> "" Then $keyToRemove = ShellNewKeyName($ext) RegDelete($keyToRemove) If _RegExistKey($keyToRemove) Then MsgBoxCannotModifyRegistry() Else _GuiCtrlListBox_DeleteString($fileTypesList, _GuiCtrlListBox_FindString($fileTypesList, $ext)) EndIf Else MsgBox(0, "Error", "No Item Selected") EndIf EndSwitch WEnd Edited September 30, 2019 by gaxar77 Skeletor 1 Link to comment Share on other sites More sharing options...
spudw2k Posted September 30, 2019 Share Posted September 30, 2019 Pretty neat. I can see some room for code cleanup and optimization (removing redundant code, create functions, etc.) A cool improvement could be to add an export / import feature as well. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
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