How can we avoid executeASModal progress bar?

Hi all, Below code shows progess bar on Photoshop.
Is there any way to avoid it?

var exeModal = require('photoshop').core.executeAsModal;
 await exeModal(batchProcess);
async function batchProcess() {
  let folder = await fs.getFolder();
  const entries = await folder.getEntries();
  var files = entries.filter(async entry => {
    if (entry.isFile) {
      return true;
    }
  });

  await app.open(files[0]);
  await checkDocSize();
  await app.open(files[1]);
  await checkDocSize();
}
1 Like

What does checkDocSize() do? Is it a heavy function? Progress bar is shown if exeModal takes longer than approx 2 seconds. How long are you searching for the folder? I don’t think you need modal for the picker. Try this:

var exeModal = require('photoshop').core.executeAsModal;

  let folder = await fs.getFolder();
  const entries = await folder.getEntries();
  var files = entries.filter(async entry => {
    if (entry.isFile) {
      return true;
    }
  });

await exeModal(batchProcess);
async function batchProcess() {
  await app.open(files[0]);
  await checkDocSize();
  await app.open(files[1]);
  await checkDocSize();
}

Also, do you really need to await for exeModal itself?

Yes checkDocSize() function process is longer It is doing lot more things.
Using await for exeModal because I want to synchronize the process for every file one by one.
so, if process is longer than 2 sec then we cannot avoid progress bar?

So what happens if you keep await inside exeModal, but remove from it itself?

If I remove await from exeModal then It does not work in synchronized way.

That’s weird :confused: Did you leave all the awaits inside batchProcess()?

Just tested and it seems to be working fine file by file with waiting for the delay:

var exeModal = require('photoshop').core.executeAsModal;
var fs = require("uxp").storage.localFileSystem;

let folder = await fs.getFolder()
let entries = await folder.getEntries()
let files = entries.filter(entry => entry.isFile)

function wait(milliseconds) {
    return new Promise(resolve => setTimeout(resolve, milliseconds));
}

exeModal(batchProcess);
async function batchProcess() {
    let now = new Date()
    
    for (const file of files) {
        await wait(1000)
        console.log(`Seconds passed: ${((new Date()) - now) / 1000}`, file.name)
    }
}

Although, as expected, progress bar appears after ~2 seconds:

If you use interactive mode, then progress bar is not shown, but Ps is frozen and user cannot interact anyway. This is expected I suppose, because interactive mode is not meant for such cases

exeModal(batchProcess, {"interactive": true});

How can I achieve below progress bar style using exeModal?

Did you check the docs? It appears automatically if script takes a bit longer

By default below progress bar style is showing:


But I want to achieve below progress bar style:

How can we manipulate exeModal progress bar color etc.?

I believe it’s just the default styling depending on OS
I assume the second one is on MacOS

1 Like

A post was split to a new topic: executeAsModal isCanceled does not work