Copy link to clipboard
Copied
Hi Folks,
So i searched quite a bit and could not land on any meaningful documentation around this aspect of PS scripting. I am clear that this provides us access to low level functionality not exposed on the DOM but beyond this i am lost. Some questions that might be trivial are listed below
I see lots of code snippets shared, but none gives an insight as to how it was written, how did you get to know the values used as arguments. Any pointers to a proper documentation would be helpful
Thanks
-Manan
I started writing scripts a little over a year ago when I did not find a programmer to solve a specific problem, so maybe my experience will come in handy (I apologize in advance - I use a translator to write all this, so some wording may be incorrect).
For most tasks, three things are enough to write Action Manager code: to know the names of all top-level objects, to have at hand a set of functions for each type of objects from the Photoshop JavaScript Reference Guide ADOBE PHOTOSHOP SCRIPTING,
...Copy link to clipboard
Copied
Copy link to clipboard
Copied
I've just started to venture down this rabbit hole. I found that I wasn't able to understand how the calling convention worked. I kept seeing ActionDescriptors with null key references, but couldn't put it all together. Reading through the Scripting Listener logs didn't help either. So I came up with a way to convert the Scripting Listener to a more conventional calling syntax;
save | save (Enumerated<saveStageType>: saveStage, Integer: DocI|documentID, Path: In|in, Object<PNGF>: As)
saveStage: saveStageType.saveBegin
DocI|documentID: (unique document identifier)
In|in: Path("/file")
As|as: PNGF|PNGFormat(Enumerated<PNGMethod>: Mthd|method)
Mthd|method: PNGMethod.thorough
This captures all the information to make the ActionDescriptor/ActionReference style calling. I find presents it in a more conventional programming style. As there is quite an unusual type of information, I've had to be a bit creative with the syntax decorations.
This says that the 4 cc code for the executeAction "save" is also the same for the string. Requires 4 parameters to be placed in the top level Action Descriptor. Of type Enumerated, type Integer, type Path and type Object. Enumerators have 2 values associated with their key, the key name is "saveStage", which doesn't have a 4cc, and it uses the enumeration type "saveStageType" I didn't put the value into the prototype, but I've include values on the following lines. In this case SaveBegin was the Enumeration value; which looks like this in original JS: desc.putEnumerated(sTT("saveStage"),sTT("saveStageType"),sTT("saveBegin"); The other confusing thing is that objects are also ActionDescriptors. So can have the same appearances as parameter lists. This shows that the PNG Format object requires 1 parameter, an Enumeration type, with 'Mthd' or "method" as its key, "PNGMethod" as the enumeration type and "thorough" as the enumeration value. Making this template for each Action Manager command I came across, made the interface seem more like a conventional one.
Copy link to clipboard
Copied
I did some research and test, and finally understood what ActionManager is and how it works.
I wrote three articles tell about:
1. how to understand ActionManager and how it works
2. how to get information from photoshop by using it
3. how to set information to photoshop by using it
these articles are writen in Chinese, you can check it from here https://uiscripting.com/2021/12/12/action-manager-part1/ and may read it with a translator.
and beyond, I made a photoshop-script-api library, which wrap many AM codes and provides an easier use api then the official DOM API, you can check it out from here
https://github.com/emptykid/photoshop-script-api
hope it helps who dived in photoshop scripting world.
Copy link to clipboard
Copied
@xiaoqiang101 – Thank you for sharing, this info is very welcome indeed!