[Scripting] help with creating progress window

I'm trying to display a progress window (like File Function progress window) in my button script to display progress as amount of bytes but whatever I try, no window appears :frowning:

Here is a minimum example of code that I've tried (one of many unsuccessful iterations).

var DOpusFactory = DOpus.Create();
var Command = DOpusFactory.Command();
var Progress = Command.progress;

Progress.bytes = true;

Progress.Init();
Progress.Show(null, "Testing");

Progress.AddFiles(1, 32768); // test
//Progress.SetFileSize(32768); // test

for (i = 0; i < 32768; i++)
{
    Progress.SetBytesProgress(i);
}

And one extra question: how to prevent auto-deselection of files after my script button operation completes? The button doesn't do anything with any selected files, so files being auto-deselected after script finishes is unrelated side-effect. I've tried the @nodeselect modifier to no avail.

function OnClick(clickData)
{
	var Command = clickData.Func.Command;
	Command.Deselect = false;
	var Progress = Command.progress;
	
	var s = 32768;

	Progress.bytes = true;
	Progress.Init(clickData.Func.sourceTab, "Testing");
	Progress.AddFiles(1, s);
	Progress.Show();

	Progress.SetFileSize(s);
	
	for (i = 1; i <= 10; i++)
	{
		DOpus.Delay(250);
		var p = Math.floor((s*i)/10);
	    Progress.SetBytesProgress(p);
	}
	Progress.FinishFile();
}
2 Likes

Thanks Leo, this is it!