Starting Opus - a question

When I start Opus, either at boot time or by double-clicking on the desktop I would like to run the following set of commands:

Go TABGROUPLOAD=Tome
Set LISTERSIZE = 2800,1840
Set LISTERPOS = 100,10
Show THUMBNAILSIZE 320

I know I can add the top line in the Prefs - and I do.but it would be very handy to extend the command to take in all four lines.

How can I do this.

Alternatively - and in some ways even better - is there a way to run those commands when a tab is opened?

1 Like

Here is a little Add-in to get you started. Be careful not to create circular references, otherwise Opus might be opening tabs until doomsday.

// myStart
// This is a script for Directory Opus.
// See https://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.

// Called by Directory Opus to initialize the script
function OnInit(initData) {
    initData.name = "myStart";
    initData.version = "1.0";
    initData.copyright = "";
    //	initData.url = "https://resource.dopus.com/viewforum.php?f=35";
    initData.desc = "";
    initData.default_enable = true;
    initData.min_version = "12.0";
}

// Called when Directory Opus starts up
function OnStartup(startupData) {
    DOpus.Output('I just started...');
}

// Called when a new tab is opened
function OnOpenTab(openTabData) {
    var cmd = DOpus.Create.Command;
    // cmd.RunCommand('Go D:\test');
    DOpus.Output('OnOpenTab got triggered');
}

myStart.js.txt (821 Bytes)

Using a Layout is probably easier than running commands.

But you can create a user command* if you want to run multiple things at startup, then put the user command into the field 8n Preferences.

(*Or a script command or script add-in, if something more complex is desired.)

But a Layout is easiest unless there's a reason using one wouldn't work.

Thanks guys. I have created a user command suggested by Leo to be used at startup and it works a treat - just what I need.

So far as the tab function mentioned by @lxp, I am a little confused. DO I simply place this in the scripts directory and then it works, or do I have to do something else?

DO I simply place this in the scripts directory and then it works

Yes. Un-comment the cmd.RunCommand line and enter whatever Opus command line you want to run.

"Select" does not seem to work when opening a new tab.

Function OnOpenTab(openTabData)
	Dim cmd
	set cmd = DOpus.NewCommand
	cmd.RunCommand "Select DATE=newest TYPE=files"
End Function

Add this line

cmd.SetSourceTab(openTabData.tab)

No luck. Does not seem to work in conjunction with "Select".

This works for me:

Function OnOpenTab(openTabData)
	Dim cmd
	set cmd = DOpus.NewCommand
    cmd.SetSourceTab(openTabData.tab)
	cmd.RunCommand "Select DATE=newest TYPE=files"
End Function

It did not work for me. Thank you for trying it.

The open tab event is fired when the tab opens, but until the folder has been read there won’t be anything to select. You probably want to use the OnAfterFolderChange event.

Great! Thank you. Worked.