popupmenu - Add nested submenus

Discuss and share scripts and script files...
Norn
Posts: 416
Joined: 24 Oct 2021 16:10

Re: popupmenu - Add nested submenus

Post by Norn »

Copyto, moveto, backupto to tab folders [edit path then paste with path]

Code: Select all

/*
******************************************************************************
@Author  : IT Services & Consulting Ulf Kohlmorgen
@Created : 2022-01-14 20:03:13
@Modified: 2022-01-14 20:09:47
@Function: Copyto, moveto, backupto to tab folders with path
@Tags    : <empty>
@Version : v0.1e
******************************************************************************
*/

    $iconFolder  = ":showfolders";
    $iconCopy    = ":copyto";
    $iconMove    = ":moveto";
    $iconBackup  = ":backupto";

    $selectedItems = <get SelectedItemsPathNames |>;
    end (!$selectedItems), "No item(s) selected, aborted!";

    $folders = "";
    if (get("#800")) { $folders .= get("tabs", <crlf>, "i"); }
    $folders .= <crlf> . get("tabs", <crlf>);
    $folders  = formatlist($folders, "esdF", <crlf>, "!" . <curpath>);
    $menu   = "";
    $indent = <space 4>;
    $last   = "";

    while ($folders) {
        $folder  = gettoken($folders, 1, <crlf>);
        $folders = gettoken($folders, 2, <crlf>, , 2);

        if ($folder != $last) {
            $caption  = gpc($folder, "component", -1);
            $menu    .= <crlf> . $caption . "<:><:>" . $iconFolder;
        }
    $path = input("Paste with path Edit: ","$selectedItems",<curitempath>,"", , 800, 171);
    $path = replace($path,:,);
    $indent = <space 4>;
    $menu .= <crlf> . $indent . "Copy <selected items> here...<:>" . $path . "<:>" . $iconCopy;

    $menu   = "";
    $indent = <space 4>;
    $last   = "";

    while ($folders) {
        $folder  = gettoken($folders, 1, <crlf>);
        $folders = gettoken($folders, 2, <crlf>, , 2);

        if ($folder != $last) {
            $caption  = gpc($folder, "component", -1);
            $menu    .= <crlf> . $caption . "<:><:>" . $iconFolder;
        }

        $data  = 'copyto ' . "'$folder" . "\" . "$path'","$selectedItems", , 2, 2;
        $menu .= <crlf> . $indent . "Copy with Path <selected items> here...<:>" . $data . "<:>" . $iconCopy;
        $data  = 'moveto ' . "'$folder" . "\" . "$path'","$selectedItems", , 2, 2;
        $menu .= <crlf> . $indent . "Move with Path <selected items> here...<:>" . $data . "<:>" . $iconMove;
        $data  = 'backupto ' . "'$folder" . "\" . "$path'","$selectedItems", , 2, 2;
        $menu .= <crlf> . $indent . "Backup with Path <selected items> here...<:>" . $data . "<:>" . $iconBackup;
        $last  = $folder;
    }
    $selection = popupnested($menu, 6:=<crlf>, 7:="<:>");
    if ($selection) { load $selection, , "s"; }
    



Copyto, moveto, backupto to tab folders [edit path then paste with path without asking]

Code: Select all

/*
******************************************************************************
@Author  : IT Services & Consulting Ulf Kohlmorgen
@Created : 2022-01-14 20:03:13
@Modified: 2022-01-15 09:23:06
@Function: Copyto, moveto, backupto to tab folders with path without asking
@Tags    : <empty>
@Version : v0.1e2
******************************************************************************
*/

    $iconFolder  = ":showfolders";
    $iconCopy    = ":copyto";
    $iconMove    = ":moveto";
    $iconBackup  = ":backupto";

    $selectedItems = <get SelectedItemsPathNames |>;
    end (!$selectedItems), "No item(s) selected, aborted!";

    $folders = "";
    if (get("#800")) { $folders .= get("tabs", <crlf>, "i"); }
    $folders .= <crlf> . get("tabs", <crlf>);
    $folders  = formatlist($folders, "esdF", <crlf>, "!" . <curpath>);
    $path = input("Paste with path Edit:","$selectedItems" ,<curitempath>,"" , , 800, 171);
    $path = replace($path,:,);$path = replace($path,$path,"\$path");

    $menu   = "";
    $indent = <space 4>;
    $last   = "";
    $roots  = "Copyto|moveto|backupto";

    foreach($root, $roots, , "e") {
        $tmpFolders = $folders;

        switch (recase($root)) {
            case "copyto"  : $menu .= <crlf> . "Copy <selected items> here..."   . "<:><:>" . $iconCopy; break;
            case "moveto"  : $menu .= <crlf> . "Move <selected items> here..."   . "<:><:>" . $iconMove; break;
            case "backupto": $menu .= <crlf> . "Backup <selected items> here..." . "<:><:>" . $iconBackup; break;
        }

        while ($tmpFolders) {
            $tmpFolder  = gettoken($tmpFolders, 1, <crlf>);
            $tmpFolders = gettoken($tmpFolders, 2, <crlf>, , 2);

            if ($tmpFolder != $last) {
                $caption = gpc($tmpFolder, "component", -1);
            }
            $data  = $root. " " . quote($tmpFolder . $path) . ", " . quote($selectedItems) . ", , 2, 2;";
            $menu .= <crlf> . $indent . $tmpFolder . "<:>" . $data . "<:>" . $iconFolder;
            $last  = $tmpFolder;
        }
    }
    $selection = popupnested($menu, 6:=<crlf>, 7:="<:>");
    if ($selection) { load $selection, , "s"; }
Last edited by Norn on 08 Mar 2022 17:45, edited 2 times in total.
Win10, Win11 @100% 2560x1440 22H2

Norn
Posts: 416
Joined: 24 Oct 2021 16:10

Re: popupmenu - Add nested submenus

Post by Norn »

Code: Select all

/*
******************************************************************************
@Author  : Highend
@Modified: 2022-02-03 
@Function: Move <selecteditem(s) to another panel> with last folder(s)
@Version : V002
******************************************************************************
*/

    $iconFolder  = ":showfolders";
    $iconCopy    = ":copyto";
    $iconMove    = ":moveto";
    $iconBackup  = ":backupto";
    $selectedItems = <get SelectedItemsPathNames |>;

//Selected items?
    $selectedItems = <get SelectedItemsPathNames |>;
    end (!$selectedItems), "No item(s) selected, aborted!";

   
    $menu   = "";
    $indent = <space 4>;
    $path = <get path i>;                                             //get another panel path
    $foldera = gpc(<get path>,"component", -1);         //get last folder
    $folderb = gpc(<get path>,"component", -2);         //get enultimate folder
    $folderc = gpc(<get path>,"component", -3);         //get third from last folder
    $folders = $folderc . ."\" . $folderb . ."\" . $foldera;  //combination
    $folderst = $folderb . ."\" . $foldera;                       //combination
    $foldersa = replace($folders,:,);                               //replace
    $foldersb = replace($folderst,:,);                              //replace
    $foldersc = replace($folderc,:,);                               //replace

//Menu & Command...
        $data1  = 'sound'. " " . quote("C:\Windows\Media\Windows Navigation Start.wav") . ", , 1;";
        $data2  = "refreshlist i";
        $data  = 'moveto'. " " . quote("$path\$foldersa") . ", " . quote($selectedItems) . ", , 2, 2;";
        $menu .= <crlf> . $indent . "Move <selectedItem(s) to another panel> with last 3 folder...<:>" . $data . $data1 . $data2 . "<:>" . $iconMove;
        $data1  = 'sound'. " " . quote("C:\Windows\Media\Windows Navigation Start.wav") . ", , 1;";
        $data2  = 'refreshlist i';
        $data  = 'moveto'. " " . quote("$path\$foldersb") . ", " . quote($selectedItems) . ", , 2, 2;";
        $menu .= <crlf> . $indent . "Move <selectedItem(s) to another panel> with last 2 folder...<:>" . $data . $data1 . $data2 . "<:>" . $iconMove;
        $data1  = 'sound'. " " . quote("C:\Windows\Media\Windows Navigation Start.wav") . ", , 1;";
        $data2  = 'refreshlist';
        $data  = 'moveto'. " " . quote("$path\$foldersc") . ", " . quote($selectedItems) . ", , 2, 2;";
        $menu .= <crlf> . $indent . "Move <selectedItem(s) to another panel> with last folder...<:>" . $data . $data1 . $data2 . "<:>" . $iconMove;
        

        }
    }
    $selection = popupnested($menu, 6:=<crlf>, 7:="<:>");
    if ($selection) { load $selection, , "s"; }

Code: Select all

/*
******************************************************************************
@Author  : Highend
@Modified: 2022-02-03 
@Function: Move <the first item in another panel> here with last folder(s)
@Version : V001
******************************************************************************
*/
//Switch panel; select first item
focus "pi"; sel 1;

    $iconFolder  = ":showfolders";
    $iconCopy    = ":copyto";
    $iconMove    = ":moveto";
    $iconBackup  = ":backupto";
    $selectedItems = <get SelectedItemsPathNames |>;
 
    $menu   = "";
    $indent = <space 4>;
    $path = <get path i>;                                             //get another panel path
    $foldera = gpc(<get path>,"component", -1);         //get last folder
    $folderb = gpc(<get path>,"component", -2);         //get enultimate folder
    $folderc = gpc(<get path>,"component", -3);         //get third from last folder
    $folders = $folderc . ."\" . $folderb . ."\" . $foldera;  //combination
    $folderst = $folderb . ."\" . $foldera;                       //combination
    $foldersa = replace($folders,:,);                               //replace
    $foldersb = replace($folderst,:,);                              //replace
    $foldersc = replace($folderc,:,);                               //replace

//Menu & Command...
        $data1  = 'sel'. " " . quote(1) . ";";
        $data2  = 'focus'. " " . quote("pi") . ";";
        $data3  = 'sound'. " " . quote("C:\Windows\Media\Windows Navigation Start.wav") . ", , 1;";
        $data4  = 'refreshlist';
        $data  = 'moveto'. " " . quote("$path\$foldersa") . ", " . quote($selectedItems) . ", , 2, 2;";
        $menu .= <crlf> . $indent . "Move <the first item in another panel> here with last 3 folder...<:>" . $data . $data1 . $data2 . $data3 .$data4 . "<:>" . $iconMove;
        $data1  = 'sel'. " " . quote(1) . ";";
        $data2  = 'focus'. " " . quote("pi") . ";";
        $data3  = 'sound'. " " . quote("C:\Windows\Media\Windows Navigation Start.wav") . ", , 1;";
        $data4  = 'refreshlist';
        $data  = 'moveto'. " " . quote("$path\$foldersb") . ", " . quote($selectedItems) . ", , 2, 2;";
        $menu .= <crlf> . $indent . "Move <the first item in another panel> here with last 2 folder...<:>" . $data . $data1 . $data2 . $data3 .$data4 . "<:>" . $iconMove;
        $data1  = 'sel'. " " . quote(1) . ";";
        $data2  = 'focus'. " " . quote("pi") . ";";
        $data3  = 'sound'. " " . quote("C:\Windows\Media\Windows Navigation Start.wav") . ", , 1;";
        $data4  = 'refreshlist';
        $data  = 'moveto'. " " . quote("$path\$foldersc") . ", " . quote($selectedItems) . ", , 2, 2;";
        $menu .= <crlf> . $indent . "Move <the first item in another panel> here with last folder...<:>" . $data . $data1 . $data2 . $data3 .$data4 . "<:>" . $iconMove;
        

        }
    }
    $selection = popupnested($menu, 6:=<crlf>, 7:="<:>");
    if ($selection) { load $selection, , "s"; }
Last edited by Norn on 08 Mar 2022 17:51, edited 1 time in total.
Win10, Win11 @100% 2560x1440 22H2

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: popupmenu - Add nested submenus

Post by klownboy »

Hey highend, I hope all is well. The script you posted is great. Sometimes it's the simplest of scripts that are the most worthy and most used. :tup: I modified it slightly such that the tabs show their assigned icons (if any). I also present them in the same order as seen in the tab bar. It actually made it easier that way and I'm used to seeing them it that order. I hope you don't mind me posting the revision. Thanks.

Code: Select all

/*
******************************************************************************
@Author  : IT Services & Consulting Ulf Kohlmorgen
@Created : 2022-01-14 20:03:13
@Modified: 2022-01-15 09:23:06
@Function: Copyto, moveto, backupto to tab folders [operation as root]
@Tags    : <empty>
@Version : v0.1
******************************************************************************
*/

    $iconFolder  = ":showfolders";
    $iconCopy    = ":copyto";
    $iconMove    = ":moveto";
    $iconBackup  = ":backupto";
    $selectedItems = <get SelectedItemsPathNames |>;
    end (!$selectedItems), "No item(s) selected, aborted!";

   $menu   = "";
   $indent = <space 4>;
   $roots  = "Copyto|moveto|backupto";
   $cntTabs=tab("get", "c");
   foreach($root, $roots, , "e") {
        $i= "0";
        switch (recase($root)) {
            case "copyto"  : $menu .= <crlf> . "Copy <selected items> here..."   . "<:><:>" . $iconCopy; break;
            case "moveto"  : $menu .= <crlf> . "Move <selected items> here..."   . "<:><:>" . $iconMove; break;
            case "backupto": $menu .= <crlf> . "Backup <selected items> here..." . "<:><:>" . $iconBackup; break;
        }
        while ($i++ < $cntTabs) {
            $tmpFolder = tab("get", "path", $i);
            if($tmpFolder LikeI <curpath>) {continue;}
            $data  = $root. " " . quote($tmpFolder) . ", " . quote($selectedItems) . ", , 2, 2;";
            $info = tab("get", "name", $i);
            $icon = gettoken($info, 2, "|");
            if (!$icon) { $icon = ":showfolders"; }
            $menu .= <crlf> . $indent . $tmpFolder . "<:>" . $data . "<:>" . $icon;
        }
    }
    $selection = popupnested($menu, 6:=<crlf>, 7:="<:>");
    if ($selection) { load $selection, , "s"; }
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: popupmenu - Add nested submenus

Post by klownboy »

I've been using this script quite often, but there were many times I wished I could copy or move the file(s) to a sub-folder of the "tab" folder. So, I spent time giving myself a mind headache to get the script to fan out again to provide a listing of the tab's subfolders. It was tricky for an old fart like me to finally get the popupnested syntax right for the final popups. It looks like the pic below.

Because the entire menu is generated in advance, which now includes all the tab sub folders, it's a bit slow on the draw.
Highend (or anyone else), could you take a look to see if there's might be someway of speeding this up? Thanks again highend for the script.
copy move backup.jpg
copy move backup.jpg (136 KiB) Viewed 1987 times

Code: Select all

/*
******************************************************************************
@Author  : IT Services & Consulting Ulf Kohlmorgen
@Created : 2022-01-14 20:03:13
@Modified: 2022-01-15 09:23:06
@Function: Copyto, moveto, backupto to tab folders [operation as root]
@Tags    : <empty>
@Version : v0.1
******************************************************************************
*/

    $iconFolder  = ":showfolders";
    $iconCopy    = ":copyto";
    $iconMove    = ":moveto";
    $iconBackup  = ":backupto";
    $selectedItems = <get SelectedItemsPathNames |>;
    end (!$selectedItems), "No item(s) selected, aborted!";

   $menu   = "";
   $indent1 = <space 2>;
   $indent2 = <space 4>;
   $roots  = "Copyto|moveto|backupto";
   $cntTabs=tab("get", "c");
   foreach($root, $roots, , "e") {
        $i= "";
        switch (recase($root)) {
            case "copyto"  : $menu .= <crlf> . "Copy <selected items> here..."   . "<:><:>" . $iconCopy; break;
            case "moveto"  : $menu .= <crlf> . "Move <selected items> here..."   . "<:><:>" . $iconMove; break;
            case "backupto": $menu .= <crlf> . "Backup <selected items> here..." . "<:><:>" . $iconBackup; break;
        }
        while ($i++ < $cntTabs) {
            $tabFolder = tab("get", "path", $i);
            $tabFolderSubs = quicksearch("/d /md=0 ", $tabFolder);
            $tabFolderAndSubs = $tabFolder . <crlf> . $tabFolderSubs;
            $tabFolderAndSubs = formatlist($tabFolderAndSubs, "f", <crlf>,"!*Recycle*<crlf>*System Vol*<crlf>*REAgent<crlf>*Recovery");
            if($tabFolder LikeI <curpath>) {continue;}
            $info = tab("get", "name", $i);
            $icon = gettoken($info, 2, "|");
            if (!$icon) { $icon = ":showfolders"; }
            if($tabFolderSubs) {
               $menu .= <crlf> . $indent1 . $tabFolder . "<:><:>" . $icon . "<:>";}
            else {
               $dataTab  = $root. " " . quote($tabFolder) . ", " . quote($selectedItems) . ", , 2, 2;";
               $menu .= <crlf> . $indent1 . $tabFolder . "<:>" . $dataTab . "<:>" . $icon . "<:>";}
            foreach($sub, $tabFolderAndSubs, <crlf>, "e") {
               if($tabFolderSubs) {
                  $dataSub  = $root. " " . quote($sub) . ", " . quote($selectedItems) . ", , 2, 2;";
                  $menu .= <crlf> . $indent2 . $sub . "<:>" . $dataSub; }
               else {
                  $menu .= <crlf>; }
            }
        }
   }

    $selection = popupnested($menu, 6:=<crlf>, 7:="<:>");
    if ($selection) { load $selection, , "s"; }
EDIT: Updated the script such that if the tab folder has no subfolders, there is no fan out. The copy move operation is performed on the 2nd level menu.
Last edited by klownboy on 26 Feb 2022 18:11, edited 1 time in total.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: popupmenu - Add nested submenus

Post by highend »

How long does it take to build that menu (in milliseconds?)
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: popupmenu - Add nested submenus

Post by klownboy »

Hey highend, I didn't run a timer test on it but it's beyond milliseconds. Of course, it depends on the number of tabs and more importantly the number of subfolders under each one. For me with a relatively fast computer, I can count probably 2 to 3 seconds. Once that initial top menu displays it's runs fine. Thanks.

I'm going to update that last post in a minute to provide a version that doesn't fan out if there are no subs in the tab. I wasn't sure if I'd like it initially, but now I feel it's better way to go.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: popupmenu - Add nested submenus

Post by highend »

Try this instead (should need only about 1/3 of the time)...

Code: Select all

/*
******************************************************************************
@Author  : IT Services & Consulting Ulf Kohlmorgen
@Created : 2022-01-14 20:03:13
@Modified: 2022-02-26 19:28:06
@Function: Copyto, moveto, backupto to tab folders [operation as root]
@Tags    : <empty>
@Version : v0.2
******************************************************************************
*/

    $iconFolder    = ":showfolders";
    $iconCopy      = ":copyto";
    $iconMove      = ":moveto";
    $iconBackup    = ":backupto";
    $selectedItems = <get SelectedItemsPathNames |>;
    end (!$selectedItems), "No item(s) selected, aborted!";

    $menu     = "";
    $fullMenu = "";
    $indent1  = <space 2>;
    $indent2  = <space 4>;
    $roots    = "copyto|moveto|backupto";
    $tabs     = get("tabs");
    $cntTabs  = tab("get", "c");

    while ($i++ < $cntTabs) {
        $tabFolder        = tab("get", "path", $i);
        $tabFolderSubs    = quicksearch("/d /md=0", $tabFolder);
        $tabFolderAndSubs = $tabFolder . <crlf> . $tabFolderSubs;
        $tabFolderAndSubs = formatlist($tabFolderAndSubs, "f", <crlf>,"!*Recycle*<crlf>*System Vol*<crlf>*REAgent<crlf>*Recovery");
        if ($tabFolder LikeI <curpath>) { continue; }
        $info = tab("get", "name", $i);
        $icon = gettoken($info, 2, "|");
        if (!$icon) { $icon = ":showfolders"; }
        if ($tabFolderSubs) {
            $menu .= <crlf> . $indent1 . $tabFolder . "<:><:>" . $icon . "<:>";
        } else {
            $dataTab = "__OP__" . " " . quote($tabFolder) . ", " . quote($selectedItems) . ", , 2, 2;";
            $menu   .= <crlf> . $indent1 . $tabFolder . "<:>" . $dataTab . "<:>" . $icon . "<:>";
        }

        foreach($sub, $tabFolderAndSubs, <crlf>, "e") {
            if ($tabFolderSubs) {
                $dataSub  = "__OP__" . " " . quote($sub) . ", " . quote($selectedItems) . ", , 2, 2;";
                $menu    .= <crlf> . $indent2 . $sub . "<:>" . $dataSub;
            } else {
                $menu .= <crlf>;
            }
        }
    }
    $menu = trim($menu, <crlf>);

    foreach($root, $roots, , "e") {
        switch (recase($root)) {
            case "copyto"  : $fullMenu .= <crlf> . "Copy <selected items> here..."   . "<:><:>" . $iconCopy   . <crlf> . replace($menu, "__OP__", "copyto");   break;
            case "moveto"  : $fullMenu .= <crlf> . "Move <selected items> here..."   . "<:><:>" . $iconMove   . <crlf> . replace($menu, "__OP__", "moveto");   break;
            case "backupto": $fullMenu .= <crlf> . "Backup <selected items> here..." . "<:><:>" . $iconBackup . <crlf> . replace($menu, "__OP__", "backupto"); break;
        }
    }
    $selection = popupnested($fullMenu, 6:=<crlf>, 7:="<:>");
    if ($selection) { load $selection, , "s"; }
One of my scripts helped you out? Please donate via Paypal

Horst
Posts: 1085
Joined: 24 Jan 2021 12:27
Location: Germany

Re: popupmenu - Add nested submenus

Post by Horst »

Nice script but unfortunately not for dual pane users :(
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: popupmenu - Add nested submenus

Post by highend »

That requires a double focus switch...

Code: Select all

/*
******************************************************************************
@Author  : IT Services & Consulting Ulf Kohlmorgen
@Created : 2022-01-14 20:03:13
@Modified: 2022-02-26 20:36:06
@Function: Copyto, moveto, backupto to tab folders [operation as root]
@Tags    : <empty>
@Version : v0.3
******************************************************************************
*/

    $iconFolder    = ":showfolders";
    $iconCopy      = ":copyto";
    $iconMove      = ":moveto";
    $iconBackup    = ":backupto";
    $selectedItems = <get SelectedItemsPathNames |>;
    global $p_tabs = "";
    end (!$selectedItems), "No item(s) selected, aborted!";

    $dp       = get("#800");
    $fullMenu = "";
    $roots    = "copyto|moveto|backupto";

    $menu = BuildTabEntries("a");
    if ($dp) { $menu .= <crlf> . BuildTabEntries("i"); }
    end (!trim($menu, <crlf>)), "No valid destination tab(s) open, aborted!";

    foreach($root, $roots, , "e") {
        switch (recase($root)) {
            case "copyto"  : $fullMenu .= <crlf> . "Copy <selected items> here..."   . "<:><:>" . $iconCopy   . <crlf> . replace($menu, "__OP__", "copyto");   break;
            case "moveto"  : $fullMenu .= <crlf> . "Move <selected items> here..."   . "<:><:>" . $iconMove   . <crlf> . replace($menu, "__OP__", "moveto");   break;
            case "backupto": $fullMenu .= <crlf> . "Backup <selected items> here..." . "<:><:>" . $iconBackup . <crlf> . replace($menu, "__OP__", "backupto"); break;
        }
    }
    $selection = popupnested($fullMenu, 6:=<crlf>, 7:="<:>");
    if ($selection) { load $selection, , "s"; }



function BuildTabEntries($pane) {
    global $p_tabs;

    $indent1  = <space 2>;
    $indent2  = <space 4>;
    $curPath  = <curpath>;
    if ($pane LikeI "i") { focus "PI"; }

    $tabs    = get("tabs", "|");
    $cntTabs = gettoken($tabs, "count", "|");

    $menu = "";
    while ($i++ < $cntTabs) {
        $tabFolder        = tab("get", "path", $i);
        $tabFolderSubs    = quicksearch("/d /md=0", $tabFolder);
        $tabFolderAndSubs = $tabFolder . <crlf> . $tabFolderSubs;
        $tabFolderAndSubs = formatlist($tabFolderAndSubs, "f", <crlf>,"!*Recycle*<crlf>*System Vol*<crlf>*REAgent<crlf>*Recovery");
        if ($tabFolder LikeI $curPath) { continue; }             // Skip tabs with the same current path
        if (strpos($p_tabs, "|$tabFolder|") != -1) { continue; } // Skip duplicate tab paths

        $info = tab("get", "name", $i);
        $icon = gettoken($info, 2, "|");
        if (!$icon) { $icon = ":showfolders"; }
        if ($tabFolderSubs) {
            $menu .= <crlf> . $indent1 . $tabFolder . "<:><:>" . $icon . "<:>";
        } else {
            $dataTab = "__OP__" . " " . quote($tabFolder) . ", " . quote($selectedItems) . ", , 2, 2;";
            $menu   .= <crlf> . $indent1 . $tabFolder . "<:>" . $dataTab . "<:>" . $icon . "<:>";
        }

        foreach($sub, $tabFolderAndSubs, <crlf>, "e") {
            if ($tabFolderSubs) {
                $dataSub  = "__OP__" . " " . quote($sub) . ", " . quote($selectedItems) . ", , 2, 2;";
                $menu    .= <crlf> . $indent2 . $sub . "<:>" . $dataSub;
            } else {
                $menu .= <crlf>;
            }
        }
        $p_tabs .= "|" . $tabFolder;
    }
    $p_tabs .= "|";
    if ($pane LikeI "i") { focus "PI"; }

    return trim($menu, <crlf>);
}
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: popupmenu - Add nested submenus

Post by klownboy »

Hey highend, thanks for the modification. Initially it didn't seem like there was much of a difference, but I ran SC now timer on both and set one as left click of CTB and the other as right click. Then, I picked up on a noticeable and much-improved speed difference. It's much more usable and livable now. I haven't looked over the modification in detail yet, but it's surprising that restructuring and moving the foreach and switch at the end instead of up front, made that much difference. Thanks again. :tup:
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: popupmenu - Add nested submenus

Post by highend »

It's easy. Before everything (e.g. getting subfolders) was done three times (for backup, copy and move) and now it's only done a single time and then applied to the 3 operations...
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: popupmenu - Add nested submenus

Post by klownboy »

Hey again highend, I see you answered Horst's call and posted a dual pane version. On a quick check of that v0.3, I noticed you had a duplicate tab removal line. The way it's structured it looks like it would only remove dups on the same pane. It might be nice to have them removed across panes.

The only other thing I would recommend is possibly a divider line between popup for pane "a" and "i". So, the user gets a feel for which pane tabs we're looking at. If the removal of dups across panes is a pain or awkward, the divider would certainly help. Some of us have some dups not on the same pane but in the other pane.
highend wrote: 26 Feb 2022 21:38 It's easy. Before everything (e.g. getting subfolders) was done three times (for backup, copy and move) and now it's only done a single time and then applied to the 3 operations...
Ahh yes, that would make a huge difference I'll look at it again and the newest version where you have made it a function.

Thanks again.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: popupmenu - Add nested submenus

Post by highend »

It might be nice to have them removed across panes.
It does it. Look at the small change in v0.3

Because of this it makes no sense (to me) to add a separator between panes, because eventually some tabs of the inactive one could be missing in the menu (because of deduplication) which would lead to confusion...

Additionally, I've added another check so that you get a message (and not a menu) when there is only a single tab open
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: popupmenu - Add nested submenus

Post by klownboy »

highend wrote: 26 Feb 2022 22:10 It might be nice to have them removed across panes.
It does it. Look at the small change in v0.3
I see the strpos($p_tabs... line to skip if a dup, along with $p_tabs .= "|"; located outside the while loop so I assume it suppose to catch a dup across panes, but I have 3 or 4 tabs that are the same in pane 1 as pane 2 and they show up twice. That's why I was asking. No, I don't really care about a divider. I'll look further at it.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: popupmenu - Add nested submenus

Post by highend »

You've tried the current version of v0.3? It works fine here filtering out all duplicates regardless if dual pane or not
One of my scripts helped you out? Please donate via Paypal

Post Reply