• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Unable to load action while an action is running?

Participant ,
Sep 07, 2016 Sep 07, 2016

Copy link to clipboard

Copied

I've got a script that loads an action into the actions palette:

app.load(new File('/path/to/action.atn'))

Works fine when I run it through ExtendScript Toolkit and target Photoshop CC. However, if I actually run the script through an action (so, record an action of myself opening the script and then running that action) , it does nothing. Why is that? The script works fine if I just open it by going to File -> Scripts -> Browse. I have the 2015.0.0 version of Photoshop.

Edit: I've tested it on a computer with the 2015.5.0 version of Photoshop and it works when opening through an action. Is there a reason it doesn't work on the older version?

TOPICS
Actions and scripting

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Sep 07, 2016 Sep 07, 2016

The only way I have been able to load an action file from a script and use it in the same script is by using BridgeTalk.

function btExec(code, btapp) {
  if (!btapp) { btapp = BridgeTalk.appSpecifier; }

  BridgeTalk.bringToFront(btapp);

  var bt = new BridgeTalk();
  bt.target = btapp;
  bt.body = code;
  bt.send();
};

function loadActionFile(file) {

  btExec('app.load(new File("' + file.absoluteURI + '"));');

};

The reason that this works is because it fires up a new PS/JS interpreter in a separate app thr

...

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 07, 2016 Sep 07, 2016

Copy link to clipboard

Copied

In CC 2015.5 I was not able to record Load action in an  action. It was grayed out. Even when I tried to use insert menu item,  item load action was grayed out.  Also the Scriptlistener did not record anything when I used the Action Palette's fly-out menu Load Action when I loaded an Action set.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 07, 2016 Sep 07, 2016

Copy link to clipboard

Copied

The following function made of AM code used to be equivalent to app.load:

function loadFile (file)
{
	var descriptor = new ActionDescriptor ();
	descriptor.putPath (app.stringIDToTypeID ("target"), file);
	app.executeAction (app.stringIDToTypeID ("open"), descriptor);
}

so you may want to try it instead, but it may not work either:

 

loadFile (new File ('/path/to/action.atn'))

 

HTH,

 

--Mikaeru

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Sep 07, 2016 Sep 07, 2016

Copy link to clipboard

Copied

The only way I have been able to load an action file from a script and use it in the same script is by using BridgeTalk.

function btExec(code, btapp) {
  if (!btapp) { btapp = BridgeTalk.appSpecifier; }

  BridgeTalk.bringToFront(btapp);

  var bt = new BridgeTalk();
  bt.target = btapp;
  bt.body = code;
  bt.send();
};

function loadActionFile(file) {

  btExec('app.load(new File("' + file.absoluteURI + '"));');

};

The reason that this works is because it fires up a new PS/JS interpreter in a separate app thread to hand the BridgeTalk message. If I needed to call the action immediately, I'd have to do a $.sleep() call to handle the race condition.

You might be able to add an ActionStep to call script that uses this technique. I don't recall if I've ever tried it, but it may be you're only solution if Mikaeru's doesn't work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 08, 2016 Sep 08, 2016

Copy link to clipboard

Copied

LATEST

xbytor, you beautiful fountain of knowledge. That's done the trick! Thank you!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines