Skip to main content
Participant
April 16, 2009
Question

Howto monitor/display javascript processing

  • April 16, 2009
  • 1 reply
  • 1424 views

Hi,

I've a simple, probably noob question.

I'm intersted in visually monitor/display the processing of my script.

My script is running fine, but during the whole javascript process I only see the document window with a white background, but without the image itself.

At the moment where I abort my script, the image get immediately shown.

What I miss is something like "app.activeDocument.show();"

This topic has been closed for replies.

1 reply

Inspiring
April 16, 2009

You can try this function:

function WaitForRedraw() {

     var desc = new ActionDescriptor();
     desc.putEnumerated( charIDToTypeID("Stte"), charIDToTypeID("Stte"), charIDToTypeID("RdCm")  );
     executeAction( charIDToTypeID("Wait"), desc, DialogModes.NO);
};

Or you can create a dialog with a progressbar it that doesn't work.

Joerg_E_Author
Participant
April 16, 2009

Great, fast response !!

I don't understand your code, but it's working ! ;-)

However, just found probably another solution for my problem.

It's located in the Action window menu as "Execution option" where you can set the execution to "Step by step" which also solved my problem, even if I don't know how to set this option via javascript.

Could you please drop me a short note which of the two ways looks to be the better or faster-image-processing approach ?!

I like to understand the stuff I'm writing ;-)

Lot thanks for your fast help !!

Inspiring
April 17, 2009

From a speed standpoint the script will be faster if the playback option is set to accelerated.

You could either give the user an alert at the start of the script asking them to wait while the script runs or just let the screen not refresh as you were doing. Depending on the script you could also use the wait for redraw funtion when needed. That would let the script run faster and let the user see some progress.

If the script really takes a long time a dialog with a progress bar would give the user an idea of how far along the script has run.

You can use the function below from Xbytor to set the playback options with a script. I don't think there is a way to determine the current settings.

cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

Stdlib = function Stdlib() {};

Stdlib.setActionPlaybackOptions = function(opt, arg) {
  function _ftn() {
    var desc = new ActionDescriptor();
    var ref = new ActionReference();
    ref.putProperty(cTID("Prpr"), cTID("PbkO"));
    ref.putEnumerated(cTID("capp"), cTID("Ordn"), cTID("Trgt"));
    desc.putReference(cTID("null"), ref );
    var pdesc = new ActionDescriptor();
    pdesc.putEnumerated(sTID("performance"), sTID("performance"), sTID(opt));
    if (opt == "pause" && arg != undefined) {
      pdesc.putInteger(sTID("pause"), parseInt(arg));
    }
    desc.putObject(cTID("T "), cTID("PbkO"), pdesc );
    executeAction(cTID("setd"), desc, DialogModes.NO);
  }
  _ftn();
};
Stdlib.setPlaybackAcclerated = function() {
  Stdlib.setActionPlaybackOptions("accelerated");
};
Stdlib.setPlaybackStepByStep = function() {
  Stdlib.setActionPlaybackOptions("stepByStep");
};
Stdlib.setPlaybackPaused = function(delaySec) {
  Stdlib.setActionPlaybackOptions("pause", delaySec);
};