CycleListers allows you to cycle through all open listers, similar to switching between open documents in an office program. It serves as an alternative to the Windows functions accessed via Alt-Tab or Win-Tab, offering a faster way to navigate between them. The order in which the listers are activated is determined by their window handles (HWND). The listers will be cycled in an endless loop.
Three arguments are supported:
Argument | Description |
---|---|
LASTACTIVE | Activate the last active lister. This lets you quickly switch between two listers. Takes priority over the other arguments. |
REVERSE | Reverse the looping direction. |
ONLYCURRENTDESKTOP | Ignore listers on other virtual desktops. |
CycleListers works everywhere. I recommend putting it on global hotkeys.
How to set up and use
Save CommandCycleListers.js.txt to ↓
%appdata%\GPSoftware\Directory Opus\Script AddIns
Add the new command to a hotkey.
CycleListers
<?xml version="1.0"?>
<button backcol="none" display="label" hotkey="win+alt+f6" textcol="none">
<label>CycleListers</label>
<function type="normal">
<instruction>CycleListers</instruction>
</function>
</button>
CycleListers REVERSE
<?xml version="1.0"?>
<button backcol="none" display="label" hotkey="win+alt+f7" textcol="none">
<label>CycleListers</label>
<function type="normal">
<instruction>CycleListers REVERSE</instruction>
</function>
</button>
CycleListers LASTACTIVE
<?xml version="1.0"?>
<button backcol="none" display="label" hotkey="win+alt+f8" textcol="none">
<label>CycleListers</label>
<function type="normal">
<instruction>CycleListers LASTACTIVE</instruction>
</function>
</button>
The script creates a global variable
listerCount
. It could be used to hide a button if only one lister is open:
@hideif:=Val("$glob:listerCount")<2
CycleListers LASTACTIVE
It also creates the global variable lastLister
that contains the last lister's HWND. Outside of debugging scripts, its usefulness is probably rather limited.
Things you might enjoy reading
FAQ How to use buttons and scripts from this forum
The script's inner workings
JScript
function OnInit(initData) {
initData.name = 'CycleListers';
initData.version = '2024-07-05';
initData.url = 'https://resource.dopus.com/t/cyclelisters-cycle-through-listers/51247';
initData.desc = 'Cycle through Listers';
initData.default_enable = true;
initData.min_version = '12.0';
}
function OnAddCommands(addCmdData) {
var cmd = addCmdData.AddCommand();
cmd.name = 'CycleListers';
cmd.method = 'OnCycleListers';
cmd.desc = 'Cycle through Listers';
cmd.label = 'CycleListers';
cmd.template = '' +
'lastactive/s,' +
'reverse/s,' +
'onlycurrentdesktop/s';
cmd.hide = false;
cmd.icon = 'script';
}
function OnCycleListers(scriptCmdData) {
if (DOpus.listers.count < 2) return;
var cmd = scriptCmdData.func.command;
var args = scriptCmdData.func.args;
var vec = DOpus.Create().Vector();
var listerToActivate;
cmd.deselect = false;
if (args.lastactive &&
DOpus.vars.Exists('lastLister') &&
DOpus.vars.Get('lastLister') != String(DOpus.listers.lastactive) &&
ListerExists(DOpus.vars.Get('lastLister'))) {
listerToActivate = DOpus.vars.Get('lastLister');
} else {
for (var i = 0; i < DOpus.listers.count; i++) {
var item = DOpus.listers(i);
if (args.onlycurrentdesktop &&
item.desktop != DOpus.listers.lastactive.desktop) continue;
var listerID = Number(String(item)); // the lister's HWND
vec.push_back(listerID);
if (item.lastactive) var lastActiveListerID = listerID;
}
if (vec.count < 2) return;
vec.sort();
var k = 0;
while (vec(k) != lastActiveListerID) k++;
if (args.reverse) {
k--;
if (k < 0) k = vec.count - 1;
} else {
k++;
if (k == vec.count) k = 0;
}
listerToActivate = vec(k);
}
cmd.SetSourceTab(DOpus.listers(listerToActivate).activetab);
cmd.RunCommand('Set LISTERCMD=tofront');
}
function OnActivateLister(activateListerData) {
DOpus.vars.Set('listerCount', DOpus.listers.count); // reference as {$glob:listerCount} or Val("$glob:listerCount")
if (!activateListerData.active) {
DOpus.vars.Set('lastLister', String(activateListerData.lister));
}
var cmd = DOpus.Create().Command();
cmd.UpdateToggle();
}
function ListerExists(listerID) {
for (var i = 0; i < DOpus.listers.count; i++) {
if (String(DOpus.listers(i)) == String(listerID)) return true;
}
return false;
}