Skip to main content
rechmbrs
Inspiring
January 28, 2018
Answered

End of jsx script let user choose when to finish

  • January 28, 2018
  • 3 replies
  • 3645 views

We converted an ATN to JSX and in the ATN the STOP command was used.  STOP was converted properly but what is needed in JSX is that stop needs to wait for user to complete the task at that time.  The action leaves things running as is so user can finish and the Click PLAY to resume.  The user is using the select tool when the stop is done.

Any to do in JSX?

RONC

This topic has been closed for replies.
Correct answer JJMack

That won't change anything you save variables to disk or they will be part of environment. Problem with true, false in function I just solved other way to stop script and continue it, and it's not something I thought up, but xbytor2 so you should ask for him or someone who uses such scripts. If you kept functions in your script but didn't post them here and getting error that function doesn't exist then investigate why that happen. I can not be any of help when I don't see code.


The basic problem is Action stop brake the action into parts.  Each part is player by the user clicking the play button to play the next part of the action and the same document need to be the active document in the right state.

The easiest way to convert this type of action to a script is use X's action file to script then brake the script produced into the Action Parts.   If there are two stops in an action there would be three scripts.   ActionPart1 ActionPart2 ActionPart3. Instead of clicking the Play button to  play the next part  of the action you run the next script part.

3 replies

JJMack
Community Expert
Community Expert
January 28, 2018

There are two kinds of stops in Actions.   Stop and Stops with continue.  Both can stop the playing of the action and leave the Action position to start playing at the next step in the action after the stop step.  You can do anytime you want in Photoshop and when done click play to continue the action.  The difference between the two stops is the if you juste wanted to put our a message to the user Stop with conduce allows the user to just to acknowledge that they saw the mess by pressing enter and the action continues. That is like an alert in a script.  There is no concept stop in scripting where a script can be started from a different step.  You would need to program the script with some logic that would know what part of the script to run each time you run it.   I use the document metadata instruction field to record that information.  The first my scripts of this type does is look to see what it has recorded there. If it finds none of its recordings in there it know it the first time the script is being run on this document to do its stuff. So it runs part 1 which notes in the instruction field its information and ends execution which could be a message to the user to do something and run the script again.  The next time the script is run on the document the script will rune the next part. If part is the last part all of the scripts information will be removed from the instruction field and the scrip will end execution.  The  allows the full process  be done more the one time on a document.

My script all use the instruction field and do not interfere with each be preserving data in the field which is not theirs.    My scripts for the most part do not put out message and the user does not know they are using the script more than one.  Most of my scripts of the scripts of this type I have were written for use within Actions or toggle function for documents.   They are more or less like save and restore steps for action   One may save the resolution and ruler in use for the Document  in the instruction field. Than action  is free to  scale the document to a known size without reapplying. The resize a watermark for this size document or select a font size for this size document  add the text or watermark then run the script a second time to restore the document resolution  scale it back to it original scale..

However Adobe added a bug into scripting in CC 2015.5 and will not allow  you to set the instruction files back to null if it were null to begin with. So I set up script event manager new document and open document event to add garbage to the instruction field if it is not in there so the field will not be null.

Adobe add some strang bugs and makes statemnts like its bad to remove copyrights.  I do not understand that for they let your set the copyright to anything yow want to using Photoshop's file info.  I was jsut trying to set the instruction filed to what it was without the scripts information.

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

Official Response

Hi John, after some investigation, this new behavior is as-designed:

From the engineer: This was an intentional change to better preserve metadata during collisions from other applications:

"The new logic can lead to some cases where the user deleted information in another application and it reappears in Photoshop because it was not deleted in all instances (we have at least one source for the info, but no idea of the intention behind the change). But that is much safer than deleting added information which was intended (deleting a byline, description, or copyright is BAD)."

JJMack
Geppetto Luis
Legend
January 28, 2018

if you want to intervene with a block

you have to put the block

example

step8 (true, true)

Kukurykus
Legend
January 28, 2018

I completetly don't understand your answer to him

Geppetto Luis
Legend
January 28, 2018

Kukurykus

I think I understand that he would like to stop the script

with a stop like in the example below

//#target photoshop

//

// test.jsx

//

//

// Generated Sun Jan 28 2018 18:15:39 GMT+0100

//

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

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

//

//==================== test ==============

//

function test() {

  // Crea

  function step1(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putClass(cTID('Lyr '));

    desc1.putReference(cTID('null'), ref1);

    executeAction(sTID('make'), desc1, dialogMode);

  };

  // Unisci visibili

  function step2(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    desc1.putBoolean(cTID('Dplc'), true);

    executeAction(sTID('mergeVisible'), desc1, dialogMode);

  };

  // Imposta

  function step3(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));

    desc1.putReference(cTID('null'), ref1);

    var desc2 = new ActionDescriptor();

    desc2.putString(cTID('Nm  '), "layer test");

    desc1.putObject(cTID('T   '), cTID('Lyr '), desc2);

    executeAction(sTID('set'), desc1, dialogMode);

  };

  // Crea

  function step4(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putClass(sTID("contentLayer"));

    desc1.putReference(cTID('null'), ref1);

    var desc2 = new ActionDescriptor();

    var desc3 = new ActionDescriptor();

    var desc4 = new ActionDescriptor();

    desc4.putDouble(cTID('Rd  '), 174.000004827976);

    desc4.putDouble(cTID('Grn '), 70.2840457856655);

    desc4.putDouble(cTID('Bl  '), 70.2840457856655);

    desc3.putObject(cTID('Clr '), sTID("RGBColor"), desc4);

    desc2.putObject(cTID('Type'), sTID("solidColorLayer"), desc3);

    desc1.putObject(cTID('Usng'), sTID("contentLayer"), desc2);

    executeAction(sTID('make'), desc1, dialogMode);

  };

  // Imposta

  function step5(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));

    desc1.putReference(cTID('null'), ref1);

    var desc2 = new ActionDescriptor();

    desc2.putEnumerated(cTID('Md  '), cTID('BlnM'), cTID('SftL'));

    desc1.putObject(cTID('T   '), cTID('Lyr '), desc2);

    executeAction(sTID('set'), desc1, dialogMode);

  };

  step1();      //

  step2();      //

  step3();      //

  step4(true, true);   

  step5();      //

};

//=========================================

//                    test.main

//=========================================

//

test.main = function () {

  test();

};

test.main();

// EOF

"test.jsx"

// EOF

Kukurykus
Legend
January 28, 2018

Post your code (at least that working part with a problem) so I'll make modification. It's hard to talk about thing I don't see.