Thanks for the guidance @highend! I read the docs on
popupnested() and after some trial and error, I wrote a small script that fits my initial needs. I am no longer using the 'Open with...' menu, instead I'm loading this script using a keyboard shortcut...
Code: Select all
/*
A customized context menu for accessing common shortcuts/programs/folders
1 space per submenu
DISPLAY;DATA;ICON;STATE
*/
$menu = <<<MENU
F) Favorites;;
This PC;goto "%computer%";"%computer%"
Downloads;goto "%userreal%\Downloads\";"%userreal%\Downloads\"
PortableApps;goto "<xypath>..\..\";"<xypath>..\..\"
User;goto "%user%";"%user%"
GitBash;goto "<xypath>..\..\GitPortable\data\home\";"<xypath>..\..\GitPortable\data\home\"
Rainmeter;goto "<xypath>..\..\Rainmeter\skins\";"<xypath>..\..\Rainmeter\skins\"
Vim-Like;goto "<xypath>..\..\_programs_\AutoHotKey\Vim-Like\";"<xypath>..\..\_programs_\AutoHotKey\Vim-Like\"
1) Open in GitBash;run "<xypath>..\..\GitPortable\Wrapper-GitBashPortable.exe" <selitems>;"<xypath>..\..\GitPortable\Wrapper-GitBashPortable.exe"
2) Open in Vim;run "<xypath>..\..\GitPortable\Wrapper-Vim.exe" <selitems>;"<xypath>..\..\GitPortable\Wrapper-Vim.exe"
3) Open in Notepad++;run "<xypath>..\..\Notepad++Portable\Notepad++Portable.exe" <selitems>;"<xypath>..\..\Notepad++Portable\Notepad++Portable.exe"
4) Open in OniVim;run "<xypath>..\..\OniVim2\Oni2_editor.exe" <selitems>;"<xypath>..\..\OniVim2\Oni2_editor.exe"
5) Open in VSCode;run "<xypath>..\..\VisualStudioCode\Wrapper-VSCode.exe" <selitems>;"<xypath>..\..\VisualStudioCode\Wrapper-VSCode.exe"
6) Open in MPC-BE;run "<xypath>..\..\MPC-BEPortable\MPC-BEPortable.exe" <selitems>;"<xypath>..\..\MPC-BEPortable\MPC-BEPortable.exe"
7) Open in MediaInfo;run "<xypath>..\..\MediaInfoPortable\MediaInfoPortable.exe" <selitems>;"<xypath>..\..\MediaInfoPortable\MediaInfoPortable.exe"
8) Open in BulkRename Utility;run "<xypath>..\..\Bulk Rename Utility\Bulk Rename Utility.exe" <selitems>;"<xypath>..\..\Bulk Rename Utility\Bulk Rename Utility.exe"
0) General;;"<xypath>\data\icons\general.ico"
1) Scripts;;"<xypath>\data\icons\scripts.ico"
MangaAI: Organize;run "<xypath>..\..\_programs_\Command\WinPython\WinPython Interpreter.exe" "<xypath>..\..\_programs_\Command\MangAI\organize.py" <selitems>;"<xypath>\data\icons\python.ico"
MangaAI: Kobo;run "<xypath>..\..\_programs_\Command\WinPython\WinPython Interpreter.exe" "<xypath>..\..\_programs_\Command\MangAI\kobo.py" <selitems>;"<xypath>\data\icons\python.ico"
2) PortableApps;run "<xypath>..\..\..\Start.exe";"<xypath>..\..\..\Start.exe"
MENU;
$command = popupnested($menu);
if ($command != '') {$command};
After getting what I wanted to work, I decided to try taking it a step further and also add my favorite folders to the menu (So that I have access to everything in a single place). Right now I'm just trying to work out 2 issues...
1) Getting a variable to run as a literal command:
popupnested() returns the data as a string (I believe), so I'm looking for some kind of
execute_string_as_command($command) function that will perform the string as a literal command. Before trying to add my favorite folders, I could simply use
run $command and it would work fine. However, because folders require the
goto command, I need to be able to differentiate which command should be used. If I can't run a string as a literal command, I think my best bet is to put a placeholder in the front of the data, parse that placeholder, and then run the appropriate command based on the results (either 'run' or 'goto') .
2) Getting the menu to pop-up above the selected item or alternatively at the corner of the window, NOT under the cursor: My cursor is usually hidden along the edge of my screen, a not very practical location, so having to scan for it is a little annoying. The docs say
popupnested() is nearly identical to
popupmenu() (which accepts x/y arguments), but I can't get it to work. I would definitely prefer the menu appearing above the selected item, but a fixed location in the window is fine too.