From f9bb949fd58ca57a63b9a26479fa4ff16f3c30f7 Mon Sep 17 00:00:00 2001 From: Homes32 Date: Mon, 6 Jan 2025 20:36:53 -0600 Subject: [PATCH] Improved handling of open/edit for .au3 files in PreShell interface. --- Projects/PhoenixPE/Shell/000-PreShell.script | 22 +++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Projects/PhoenixPE/Shell/000-PreShell.script b/Projects/PhoenixPE/Shell/000-PreShell.script index dc2648f..96f7a12 100644 --- a/Projects/PhoenixPE/Shell/000-PreShell.script +++ b/Projects/PhoenixPE/Shell/000-PreShell.script @@ -181,10 +181,14 @@ End // with AutoIt so they have access to documentation, syntax checker, autocomplete, function reference, etc. // To get around this issue we attempt to resolve the editor in the following order: // 1. Check to see if the .au3 file extension is registered on the host computer. -// If so launch ShellExecute with the 'Edit' verb to open the default editor associated with .au3 files. -// 2. If the .au3 file extension is not registered, read the default custom editor from PEBakery's settings. +// If so check to see if the 'Edit' verb is defined, if so launch ShellExecute with the 'Edit' verb +// to open the default editor associated with .au3 files. +// 2. If the 'Edit' verb is not defined check to see of the 'Open' verb is. It could be that AutoIt +// is not installed but another application has been registered to open .au3. If this is the case +// launch ShellExecute with the 'Open' verb. +// 3. If the .au3 file extension is not registered at all, read the default custom editor from PEBakery's settings. // If a custom editor is defined, then launch ShellExecute with the 'Open' using the custom editor. -// 3. If the .au3 file extension is not registered and no custom editor is defined in the settings, then +// 4. If the .au3 file extension is not registered and no custom editor is defined in the settings, then // edit with notepad.exe. // Related........: btn_EditProjectConfig // =============================================================================================================================== @@ -193,10 +197,14 @@ Echo,"Opening PhoenixPE.au3 in your default editor.#$x#$xPlease close the editor ExtractAllFiles,%ScriptFile%,config,%ProjectTemp% Hash,SHA256,"%ProjectTemp%\PhoenixPE.au3",%PreEditHash% -If,ExistRegSubKey,HKCR,".au3",ShellExecute,Edit,"%ProjectTemp%\PhoenixPE.au3" +Set,%au3DefaultValue%,"DummyValue" +If,ExistRegSubKey,HKCR,".au3",RegRead,HKCR,".au3","",%au3DefaultValue% + +If,ExistRegSubKey,HKCR,"%au3DefaultValue%\Shell\Edit\Command",ShellExecute,Edit,"%ProjectTemp%\PhoenixPE.au3" +Else,If,ExistRegSubKey,HKCR,"%au3DefaultValue%\Shell\Open\Command",ShellExecute,Open,"%ProjectTemp%\PhoenixPE.au3" Else,Begin - // The .au3 file extension is not associated with anything; fallback to the PEBakery custom editor. - IniRead,"%BaseDir%\PEBakery.ini","Interface","CustomEditorPath",%CustomEditorPath%,"Default=notepad.exe" + // Fallback to the PEBakery custom editor or notepad. + IniRead,"%BaseDir%\PEBakery.ini","Interface","CustomEditorPath",%CustomEditorPath% If,%CustomEditorPath%,Equal,"",Set,%CustomEditorPath%,"notepad.exe" ShellExecute,Open,%CustomEditorPath%,"%ProjectTemp%\PhoenixPE.au3" End @@ -304,7 +312,7 @@ fb_UserConfigFile=,1,13,15,245,517,20,file,"Title=Select your config file","Filt lbl_AdditionalConfig="You may choose to include an additional AutoIt3 or PECMD configuration script in your project.#$x#$xThis script will be executed after the initial project configuration has been completed, but before the shell (explorer, etc.) is started.#$x#$xThe script will be placed on the root of the boot media as [PhoenixPE-UserConfig]. This allows the configuration to be manually edited on-the-fly (if the media is Read/Write) without rebuilding the project.",1,1,17,130,602,92,8,Normal btn_GenerateSampleConfig="Sample Config",1,8,539,245,80,20,GenerateSampleConfig,0,True,"__Generate a sample configuration file." bvl_AdvancedOptions="Advanced Options",0,12,5,290,625,71,8,Bold -cb_CustomConfigFile="Override the project config and use a custom PhoenixPE.au3 file. (DANGER!)",0,3,15,308,508,18,False,"__If enabled this PhoenixPE.au3 file will be used instead of the project's configuration.#$x#$xWARNING: This option is absolutely unsupported and, unless you are a developer,#$xthere is a good probability that you will break things. Use at your own risk." +cb_CustomConfigFile="Override the project config and use a custom PhoenixPE.au3 file.",0,3,15,308,508,18,False,"__If enabled this PhoenixPE.au3 file will be used instead of the project's configuration.#$x#$xWARNING: This option is absolutely unsupported and, unless you are a developer,#$xthere is a good probability that you will break things. Use at your own risk." fb_CustomConfigFile=,0,13,15,328,602,20,file,"Title=Select your custom PhoenixPE.au3 file","Filter=AutoIt3 Scripts|*.au3|All Files|*.*" [InterfaceEncoded]