Page 1 of 1
close multi tabs
Posted: 12 Dec 2023 22:05
by zzjean
Good evening
Is it possible to close any multiple tabs with a single command or click?
For example in Firefox, I can select tabs (with + CRTL click) and then with a single click, close them all at once.
Maybe it already exists - I searched, but couldn't find anything like it.
I think that would be handy
Thank you
Re: close multi tabs
Posted: 12 Dec 2023 22:28
by highend
No there isn't but XY has scripting support?
Code: Select all
$cntTabs = gettoken(get("tabs"), "count", "|");
$paths = "";
while ($i++ < $cntTabs) {
$name = tab("get", "name", $i);
if ($name == "") { $name = tab("get", "caption", $i); }
$paths .= $name . "|" . $i . "|" . "*" . <crlf>;
}
$ids = inputselect("Check tab(s) to close...", $paths, <crlf>, 1+2+32+128+1024+8192+16384, , 500, 600);
$cntClosed = 1;
$firstClosed = false;
foreach($id, $ids, <crlf>, "e") {
if ($firstClosed) {
$id -= $cntClosed;
$cntClosed++;
}
tab("close", 0, $id);
$firstClosed = true;
}
Re: close multi tabs
Posted: 12 Dec 2023 23:38
by zzjean
ok thank you. Its Nice and it does what I want. But it don't give me the name of the pane
Re: close multi tabs
Posted: 13 Dec 2023 13:11
by highend
Get the code again, I've changed it slightly
Re: close multi tabs
Posted: 13 Dec 2023 13:50
by zzjean
Hi,
Thank you very much it works perfectly now
It's fine and very useful.
Re: close multi tabs
Posted: 18 Mar 2024 11:01
by zzjean
Bonjour,
I used parts of 2 scripts kindly given by Highend (thanks to him).
This allows me to close the tabs in one panel then in the other.

- script.png (39.35 KiB) Viewed 1282 times
I get this:

- ecran1.png (17.13 KiB) Viewed 1282 times
Then :

- ecran2.png (22.76 KiB) Viewed 1282 times
1 - Is it possible to change the โ?โ icon. ยป for p1 and p2 and also for virtual folders.
2 โ I have to empty the variables so that the script runs correctly a second time. Is there a command to reset all variables?
Thank you for your help
Re: close multi tabs
Posted: 18 Mar 2024 11:27
by highend
Check the inputselect() options to show generic icons. Maybe that fixes that.
Empty variables to let it run a second time? Em, what?
Be more specific, show the relevant code where something doesn't work as expected and generally, post code in text form, not as an image^^
Re: close multi tabs
Posted: 18 Mar 2024 17:23
by zzjean
It took me a long time to understand how to use inputselect() with style 1024 but I succeeded for the first part p1 and p2.
On the other hand, I don't see how to do it with the second part.
For variables, in fact it's only $i of the loop :
while ($i++ < $cntTabs) {
$name = tab("get", "name", $i);
if ($name == "") { $name = tab("get","caption" , $i); }
$paths .= $name . "|" . $i. "|" . "*". <crlf>;
}
which does not reset. i.e. if I have 4 tabs in the first panel, the count starts again at 5 for the second iteration of the loop. So I display 5 fewer panels.
But maybe this is normal.
The script :
While($n<2) { $n++;
$dstpanes = <<<>>>
p1|p1|C:\Users\Utilisateur\AppData\Roaming\XYplorer\Icons\cd.ico
p2|p2|C:\Users\Utilisateur\AppData\Roaming\XYplorer\Icons\cd.ico
>>>;
$dstpanes = inputselect("Select pane(s)", $dstpanes, <crlf>, 1+2+32+16384, , 600, 500);
focus "$dstpanes";
$cntTabs = gettoken(get("tabs"), "count", "|");
$paths = "";
while ($i++ < $cntTabs) {
$name = tab("get", "name", $i);
if ($name == "") { $name = tab("get","caption" , $i); }
$paths .= $name . "|" . $i . "|" . "*" . <crlf>;
}
$ids = inputselect("Check tab(s) to close...", $paths, <crlf>, 1+2+32+128+1024+8192+16384, , 500, 600);
$cntClosed = 1;
$firstClosed = false;
foreach($id, $ids, <crlf>, "e") {
if ($firstClosed) {
$id -= $cntClosed;
$cntClosed++;
}
tab("close", 0, $id);
$firstClosed = true;
}
$i=""; } ;
Re: close multi tabs
Posted: 18 Mar 2024 17:52
by highend
If you need to reset a variable before it's e.g. counted up in a next loop again, just set it to e.g. 0 before
Code: Select all
while ($i++ < $cntTabs) {
...
}
$i = 0;
while ($i++ < $cntTabs) {
...
}
Re: close multi tabs
Posted: 18 Mar 2024 18:11
by zzjean
OK Thank you