Show message in the status bar for a few seconds

[Edit: Updated to reflect @Leo's helpful (two) words of wisdom.]

Hi all,

after reading this post, I decided to give it a try: Temporarily show a message in the status bar and then remove it again. Thanks to @Wombat for the interesting idea!

It took longer than expected (doesn't it always? :wink:) but I think I have a workable solution, though it's not very pretty. The crucial point is that my script can continue after setting the message; it doesn't have to wait for whatever amount of time until it can be cleared again.

JS/WSH in the context of DOpus doesn't seem to offer anything to facilitate that (no sleep() or setTimeout()) and so far DOpus itself hasn't provided any solution either there's DOpus.Delay (thanks, @Leo!) to let a script sleep but there's no simple way to handle the clearing asynchronously. After a lot of failed experiments I decided it's best to use dopusrt.exe for this because it can be called asynchronously and still access my DOpus variable.

The following is a rudimentary version of my solution, using a global variable tempStatus.

Step 1
Edit your status bar and add something like
Of course, you can use evaluators to add all kinds of logic, colorize the message and remove (parts of) the normal status bar content while a message is shown.

Step 2
Add a user command "clearTempStatusVar" (really imaginative, I know. If you want to change it, note that it's used in step 3 below) with the template


function OnClick(data) {

  var seconds = data.func.argsmap.exists("SECONDS") ? data.func.argsmap("SECONDS") : 3;
  if (!data.func.argsmap.exists("VAR")) {
    DOpus.Output("command clearTempStatusVar missing parameter VAR!", true);
	return true;
  var varname = data.func.argsmap("VAR");

  DOpus.Output("Waiting " + seconds + "s to delete variable '" + varname + "'...");

  DOpus.Delay(seconds * 1000);

  // make sure to update all the buttons/status bars/... where the variable is used:

  DOpus.Output("...and it's gone!");

Before @Leo's input my solution used a DOS timeout:

Old code
@output:Waiting &SECONDS&s to delete variable "&VAR&"...

// yes, I know, it's ugly: I'm (ab)using a command from the world of batch files
// wait:
@sync:timeout &SECONDS&

// this deletes the variable:
@Set glob:&VAR&
// make sure to update all the buttons/status bars/... where the variable is used:

@output:...and it's gone!

Here's the complete (new) user command:
clearTempStatusVar.ouc (1.6 KB)

Step 3
Somewhere in your code, do something like this:

  DOpus.Output("Setting variable...");

  // needs to match the variable used in the status bar:
  var VAR_NAME = "tempStatus";
  var SECONDS = 5;
  var MESSAGE = "hello, dopus!";

  DOpus.Vars.Set(VAR_NAME, MESSAGE);
  // make sure to update all the buttons/status bars/... where the variable is used:

  // now dopusrt is called with the user command to wait and then delete the variable
  // this call is asynchronous; the script doesn't wait for a result
  var shell = new ActiveXObject("WScript.Shell");
  var dopusrt = DOpus.FSUtil.Resolve("/programfiles\\GPSoftware\\Directory Opus\\dopusrt.exe");
  shell.Exec('"' + dopusrt + '" /cmd clearTempStatusVar VAR ' + VAR_NAME + ' SECONDS ' + SECONDS);

  DOpus.Output("...and it's set!");

  // immediately continue doing whatever needs doing...

Step 4
Run your code and watch the message appearing in the status bar for 5 seconds.:smiling_face:

Obviously there's a lot of potential for improvement but perhaps someone will find this useful. If it doesn't work or you have questions, let me know.

(Now if only there was a way to show more than just the file type icons in the status bar...)

1 Like

I haven't quite got this working. The message gets set but not cleared. I'm definitely going to use this once I work out what I did wrong. Thanks for posting.

Edit: I used the template you said to, but the message I get is this

Waiting &SECONDS&s to delete variable "&VAR&"...
...and it's gone!

It works. I had a space between VAR and /K


Well damn. Thank you. I searched far and wide for "timer", "timeout", "sleep", "wait"... but "delay" was just a little too creative for me, it seems. :slightly_frowning_face:

Of course DOpus.Delay is much nicer than the DOS timeout. But the workaround using dopusrt remains necessary. I updated the first post accordingly; only the user command's inner workings have changed.

@Wombat Glad to see you find it useful!

1 Like