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

Action Manager Scripting

Community Expert ,
May 26, 2020 May 26, 2020

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

  • What is ActionDescriptor, ActionReference, ActionList etc. What do they actually map to, or in other words which one is used for what purpose
  • Using the scriptlisterner plugin we can get code to automate user actions done on the PS UI. So far so good, but what about the scenarios where we need to get values from the document. Lets take an example of counting the number or artboards in the document and then accessing properties like height. width, rotation for each of these. Where do we start for this?
  • When to use charIDToTypeID vs stringIDToTypeID. How are their arguments determined etc

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

TOPICS
Actions and scripting , SDK

Views

10.0K

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

Guide , May 26, 2020 May 26, 2020

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,

...

Votes

Translate

Translate
Adobe
LEGEND ,
May 28, 2020 May 28, 2020

Copy link to clipboard

Copied

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
Community Beginner ,
Jan 20, 2021 Jan 20, 2021

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.

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
Community Beginner ,
Nov 22, 2022 Nov 22, 2022

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.

 

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
Community Expert ,
Nov 23, 2022 Nov 23, 2022

Copy link to clipboard

Copied

@xiaoqiang101 – Thank you for sharing, this info is very welcome indeed!

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