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?
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
...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.
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
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.
Copy link to clipboard
Copied
xbytor, you beautiful fountain of knowledge. That's done the trick! Thank you!!