Running command ID #'s from script not working

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
WirlyWirly
Posts: 332
Joined: 21 Oct 2020 23:33
Location: XY 64-Bit | Win 11 @ 100% (3440x1440)

Running command ID #'s from script not working

Post by WirlyWirly »

Hello,

For over a year now, I've been using the script below as a custom right-click menu using the popupnested() command. I trigger the script using a hotkey when I have an item under selection.

It has never given me issues, but suddenly the lines containing command ID #'s are no longer working; View..., Info..., Copy to other Pane, etc.

My only guess is that there was some update that broke the last line of my script, the one that interprets if the return value was a command ID # or something else. I've looked through the update log and I can't find anything related to this issue. Any tips?

v22.90.0104

Code: Select all

/*
A collection of most-used right-click options

1 tab per submenu
DISPLAY|DATA (return value)|ICON|STATE

*/

    $menu = <<<MENU

0) Sort by...||<xyicons>\other\operations\sort.ico
    0) Date Modified|Sortby 'Modified', 'clk'|
    1) Size|Sortby 'Size', 'clk'|
    2) Extension|Sortby 'Ext', 'clk'|
    3) Date Created|Sortby 'Created', 'clk'|
    4) Name|Sortby 'Name', 'clk'|
    -
    Accessed|Sortby 'Accessed', 'clk'|
    Created|Sortby 'Created', 'clk'|
    Length|Sortby 'len', 'clk'|
    Path|Sortby 'Path', 'clk'|
    Random|#331|
    Type|Sortby 'Type', 'clk'|
    -
    Folders Apart|#333|

1) View..||<xyicons>\other\operations\view.ico
    0) Branch View|#311|:flatview
    1) List|#304|
    2) Thumbnails Medium|#307|
    3) Details|#302|
    -
    Details + Thumbnails|#303|
    Small Icons|#305|
    Large Icons|#309|
    Small Tiles|#313|
    Large Tiles|#314|
    Thumbnails Small|#306|
    Thumbnails Large|#308|

2) Open with...||<xyicons>\other\operations\open_with.ico
    1) BulkRename Utility|run lax("<xypath>..\..\Bulk Rename Utility\Bulk Rename Utility.exe" <selitems>)|"<xypath>..\..\Bulk Rename Utility\Bulk Rename Utility.exe"
    2) FileBot|run lax("<xypath>..\..\FileBot\filebot.launcher.exe" <selitems>)|"<xypath>..\..\FileBot\filebot.launcher.exe"
    3) IrfanView|run lax("<xypath>..\..\IrfanViewPortable\IrfanViewPortable.exe" <selitems>)|"<xypath>..\..\IrfanViewPortable\IrfanViewPortable.exe"
    4) MediaInfo|run lax("<xypath>..\..\MediaInfoPortable\MediaInfoPortable.exe" <selitems>)|"<xypath>..\..\MediaInfoPortable\MediaInfoPortable.exe"
    5) MP3Tag|run lax("<xypath>..\..\MP3Tag\Mp3Tag.exe" <selitems>)|"<xypath>..\..\MP3Tag\Mp3Tag.exe"
    6) MPC-BE|run lax("<xypath>..\..\MPC-BEPortable\MPC-BEPortable.exe" <selitems>)|"<xypath>..\..\MPC-BEPortable\MPC-BEPortable.exe"
    7) Notepad++|run lax("<xypath>..\..\Notepad++Portable\Notepad++Portable.exe" <selitems>)|"<xypath>..\..\Notepad++Portable\Notepad++Portable.exe"
    8) QBitTorrent|run lax("<xypath>..\..\QBittorrentPortable\QBittorrentPortable.exe" <selitems>)|"<xypath>..\..\QBittorrentPortable\QBittorrentPortable.exe"
    9) ShareX|run lax("<xypath>..\..\ShareX\ShareX.exe" <selitems>)|"<xypath>..\..\ShareX\ShareX.exe"
    -
    7-Zip|run lax("<xypath>..\..\7-ZipPortable\7-ZipPortable.exe" <selitems>)|"<xypath>..\..\7-ZipPortable\7-ZipPortable.exe"
    JavaPortable|run lax("<xypath>..\..\JavaPortableLauncher\JavaPortableLauncher.exe" <selitems>)|"<xypath>..\..\JavaPortableLauncher\JavaPortableLauncher.exe"
    GitBash|run lax("<xypath>..\..\GitPortable\Wrapper-GitBashPortable.exe" <selitems>)|"<xypath>..\..\GitPortable\Wrapper-GitBashPortable.exe"
    LibreOffice|run lax("<xypath>..\..\LibreOfficePortable\LibreOfficePortable.exe" <selitems>)|"<xyicons>\programs\libreoffice.ico"
    OniVim|run lax("<xypath>..\..\OniVim2\Oni2_editor.exe" <selitems>)|"<xypath>..\..\OniVim2\Oni2_editor.exe"
    Vim|run lax("<xypath>..\..\GitPortable\Wrapper-Vim.exe" <selitems>)|"<xypath>..\..\GitPortable\Wrapper-Vim.exe"
    VSCode|run lax("<xypath>..\..\VSCodePortapps\vscode-portable.exe" <selitems>)|"<xypath>..\..\VSCodePortapps\vscode-portable.exe"
    -
    Affinity Designer|run lax("C:\Program Files\Affinity\Designer\Designer.exe" <selitems>)|"C:\Program Files\Affinity\Designer\Designer.exe"
    Affinity Photo|run lax("C:\Program Files\Affinity\Photo\Photo.exe" <selitems>)|"C:\Program Files\Affinity\Photo\Photo.exe"
    Affinity Publisher|run lax("C:\Program Files\Affinity\Publisher\Publisher.exe" <selitems>)|"C:\Program Files\Affinity\Publisher\Publisher.exe"

3) Copy..||<xyicons>\other\operations\copy_to_clipboard.ico
    0) Absolute path(s)|copytext lax(<selitems>);|
    1) Absolute Unix-style path(s)|$files = '"/' . '<selitems :::>' . '"'; $files = regexreplace($files, ':::', '" "/'); $files = regexreplace($files, '\\', '/'); $paths = regexreplace($files, ':'); copytext $paths
    -
    Item Name(s)|#102|
    Item Path(s)|#103|
    Item Stem(s)|#113|

4) Info..||<xyicons>\other\operations\info.ico
    0) File Properties|#173|
    1) Properties|#1020|
    2) Version|#1021|
    3) Meta|#1022|
    4) Preview|#1023|
    5) Raw View|#1024|
    6) Tags|#1025|
    7) Find Files|#1058|
    8) Report|#1059|

-
6) Task Manager|run "taskmgr.exe"|"<xyicons>\programs\taskmanager.ico"
-
7) Move Up|#1056|<xyicons>\other\operations\move_up.ico
8) Move to Other Pane|#803|:dpmoveto
9) Copy to Other Pane|#804|:dpcopyto

MENU;

    // Get X/Y position of a control
    $position = controlposition('TAB 1', 0);
    $x_pos = gettoken($position, 1, '|');
    $y_pos = gettoken($position, 2, '|');

    // Display the context menu
    $command = popupnested($menu, $x_pos, $y_pos,,,,,|);

    // Run the selected command or skip if it uses an id #
    if ($command && !regexmatches($command, '^\#\d+$')) { load $command,, s; }

jupe
Posts: 3575
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Running command ID #'s from script not working

Post by jupe »

The quickfix for now would be to add a semicolon after them, eg. #333 > #333;

edit: Actually a quicker fix for you (in this case) would be to just change the last line to this (maybe temporarily):
if ($command) { load $command,, s; }

WirlyWirly
Posts: 332
Joined: 21 Oct 2020 23:33
Location: XY 64-Bit | Win 11 @ 100% (3440x1440)

Re: Running command ID #'s from script not working

Post by WirlyWirly »

Thanks, editing the last line of my script and everything is working fine.

The only reason I had a comparison there at all was because running command ID #'s with load was causing them to run 2x, which would effectively cancel the command out or cause dupe issues. Now that I think about it, that behavior is more of a bug than the current behavior.

Post Reply