Copy\Move to last active source?

I don't think Opus keeps a history list of source tabs you could access. But we can keep our own and use v13's new Evaluator to create a dynamic button :sunglasses:

Give this a try. Might need a bit of fine-tuning. I leave adding the MOVE functionality to you as a little exercise :slight_smile:

function OnInit(initData) {
    initData.name = 'LogLastSource';
    initData.version = '2023-10-06';
    initData.url = 'https://resource.dopus.com/t/copy-move-to-last-active-source/46183';
    initData.desc = '';
    initData.default_enable = true;
    initData.min_version = '12.0';
}

var vec = DOpus.Create().Vector();

function StoreLastSource(tab) {
    if (!tab) return;
    if (!tab.path) return;

    vec.push_back(tab.path);
    if (vec.count > 2) vec.erase(0);

    DOpus.Vars.Set('lastSource', vec(0));
    // DOpus.Output('lastSource: ' + vec(0));
}

function OnActivateLister(activateListerData) {
    if (activateListerData.active) return;
    StoreLastSource(activateListerData.lister.activetab);
}

Save EventLogLastSource.js.txt to

%appdata%\GPSoftware\Directory Opus\Script AddIns

Then place this button on your toolbar (paste the XML).

@label:"Copy TO=""" + Val("$glob:lastSource") + """

@nodeselect
Copy TO="{=Val("$glob:lastSource")=}"
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>@label</label>
	<icon1>#clipcopy</icon1>
	<function type="normal">
		<instruction>@label:&quot;Copy TO=&quot;&quot;&quot; + Val(&quot;$glob:lastSource&quot;) + &quot;&quot;&quot;</instruction>
		<instruction />
		<instruction>@nodeselect</instruction>
		<instruction>Copy TO=&quot;{=Val(&quot;$glob:lastSource&quot;)=}&quot;</instruction>
	</function>
</button>

How to use buttons and scripts from this forum

3 Likes