GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Duplicate current lister

This button below duplicates the current lister. That is, it creates a copy of the active Opus window including the size & layout, open folders (and folder tabs), visible panels (tree, dual file display, viewer, utility), and so on.


Here is the button in .dcf format so you can drag it to a toolbar:

Duplicate Lister.dcf (1.8 KB)


The command works by saving the lister into a layout called DuplicateLister, opening the layout, then deleting the layout to tidy things up.

After loading the layout, the new window is moved slightly so it is not directly on top of the old window.

On the first cmd.AddLine(... line, you can change these two arguments to modify which details it does or doesn't copy:

LAYOUTIGNOREFORMATS=no LAYOUTIGNORETOOLBARS=yes

The command as-is will duplicate any custom changes to folder formats used inside of folder tabs, while ignoring any custom toolbars which are open.


The .dcf file above contains this script code, which is reproduced here so you can see how it works:

function OnClick(clickData)
{
	var cmd = clickData.func.command;
	cmd.ClearFiles();

	// Save the current lister into a layout called _DuplicateLister_
	// Then load that layout, and offset the window 32,32 pixels.
	cmd.AddLine('Prefs LAYOUTNAME="_DuplicateLister_" LAYOUTSAVE=single,noupdatesettings LAYOUTCLOSELISTERS=no LAYOUTIGNOREFORMATS=no LAYOUTIGNORETOOLBARS=yes LAYOUTMOUSERELATIVE=no');
	cmd.AddLine('Prefs LAYOUT="_DuplicateLister_"');
	cmd.AddLine('[');
	cmd.AddLine('Set LISTERPOS +32,+32');
	cmd.AddLine(']');
	cmd.Run();

	// Delete the _DuplicateLister_ layout.
	// We set the source to /homeroot -- usually C:\ -- so the Delete command will not be blocked
	// if we were in a folder where deletes aren't supported (e.g. This PC).
	cmd.SetSource(DOpus.FSUtil.Resolve('/homeroot'));
	cmd.RunCommand('Delete "/dopusdata\\Layouts\\_DuplicateLister_.oll" NORECYCLE QUIET');
}

This used to be done using a non-script button, which ran these commands directly:

Prefs LAYOUTNAME="_DuplicateLister_" LAYOUTSAVE=single,noupdatesettings LAYOUTCLOSELISTERS=no LAYOUTIGNOREFORMATS=no LAYOUTIGNORETOOLBARS=yes LAYOUTMOUSERELATIVE=no 
Prefs LAYOUT="_DuplicateLister_"
[
Set LISTERPOS +32,+32
]
Delete "/dopusdata\Layouts\_DuplicateLister_.oll" NORECYCLE QUIET

However, that failed when run from the This PC folder. (We'll fix that in Opus 12.13 and above, so you could switch back to the simple non-script method then, if you prefer, but the script method should work with all current and future versions.)

1 Like