How to find ALL action manager stringID keys in jsx javascript

  • 4
  • Idea
  • Updated 6 days ago
Eureka! I just had a fore-head-slapping, why-didn't-I-think-of-this-sooner moment today and I wanted to share... Maybe someone's already thought of this and I just couldn't find it.

Photoshop's Action Manager API is... not as well documented as we'd like. Getting a list of all available stringIDs or charIDs for javascripting in a given version of photoshop has been elusive... but no longer! 

Save this as logTerminology.jsx and run it in whatever version of photoshop you want. You get a list of every available stringID in that version of PS, dumped into Terminology.jsx on your desktop. It's quick and dirty, but you can dress up the "terms +=" bit to customize the output to something more consumable. 

Not tested on OSX.

------------------------------------
logTerminology();
function logTerminology () {
    var terms="";
    var stringID, line;
    for ( var i=0; i<9999;i++)
    {
        try{
            stringID = typeIDToStringID( i );
            if( stringID.length)
            {
                terms += stringID + "\n";
            }
        } catch (e){}
        
    }
    writeTerminology(terms);
}
function writeTerminology( terminologyList ){
    // write generator config file
    var terminologyFile = new File("~/Desktop/Terminology.jsx");
    // Write to file
    if ( !terminologyFile.open( 'w' ) )
    {
      $.writeln( "Unable to open file\"" + terminologyFile + "\": " + terminologyFile.error + "." );
    }
    else if ( !terminologyFile.writeln( "" + terminologyList ) )
    {
      $.writeln( "Unable to write to file\"" + terminologyFile + "\": " + terminologyFile.error + "." );
    } else {
        
        $.writeln ("Successfully created "+terminologyFile.fsName);
        terminologyFile.close();
    }
}

----------------------

Sadly, it still can't tell you what each of those is actually for but it's a start...

Photo of Max Johnson

Max Johnson, Champion

  • 450 Posts
  • 208 Reply Likes
  • energized

Posted 1 week ago

  • 4
Photo of Jaroslav Bereza

Jaroslav Bereza

  • 779 Posts
  • 166 Reply Likes
StringIDs are dynamically asigned. So they have order number once they are used. After PS start it is about 3600 but if will use it longer and try a lot different features then the number will grow.

And some CharID doesn't have StringID.
Photo of Max Johnson

Max Johnson, Champion

  • 450 Posts
  • 208 Reply Likes
There are charIDs with no stringID? How did you find that? I'm just going off of the  
PSConstants.js from the XTools suite...
https://sourceforge.net/projects/ps-scripts/files/xtools/v2.3/

But it looks like there a stringIDs with no charID, not the other way around.

I did see that the stringID which matches a charID functionally has a totally different typeID. Yay.


Photo of Kukurykus

Kukurykus

  • 301 Posts
  • 46 Reply Likes
Clcik a link in original post of below theard so you'll see some chars with no strings I found myself:

https://forums.adobe.com/thread/2249343
(Edited)
Photo of Max Johnson

Max Johnson, Champion

  • 450 Posts
  • 208 Reply Likes
Thank you!
Photo of Jaroslav Bereza

Jaroslav Bereza

  • 779 Posts
  • 166 Reply Likes
Most of these charID without stringID can be found in currentToolOptions in App descriptor:

E.g. move tool
http://sklad.bereza.cz/00-jarda/00_screenshot/2018-09-12_001007.jpg
(dollar sign means no stringID in this picture)

If you have four character it has always charID. Because charID is calculated from ASCII values. So you can only find them if they are used.

Dynamic stringIDs are from 0 to 10 000 (or more). Static stringIDs have also charID and they have calculated value.

Photo of Kukurykus

Kukurykus

  • 301 Posts
  • 46 Reply Likes
I wrote something similar 1,5 year ago. I don't know it gives the same results and same amount of outputs. You may compare boths scripts, however once I used yours and it yielded quite many...

https://forums.adobe.com/thread/2254681
(Edited)
Photo of Max Johnson

Max Johnson, Champion

  • 450 Posts
  • 208 Reply Likes
I will download this and try it out. Looks much more thorough than my own script.
Photo of Ronald Chambers

Ronald Chambers

  • 53 Posts
  • 5 Reply Likes
I use Textpad as a Notepad remplacement and has a sort lines option which makes viewing the output more meaningful. FYI.
RONC
Photo of Kukurykus

Kukurykus

  • 301 Posts
  • 46 Reply Likes
I voted, but to be honest I don't know for what :)
Photo of Max Johnson

Max Johnson, Champion

  • 450 Posts
  • 208 Reply Likes
Interesting... I dig through Adobe's Photoshop SDK header files and found the char codes all referenced in the PITerminology.h file. This is a warning at the top of that file...:

//*****************************************************************************
// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
//
// WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
//
// This file should NO LONGER BE USED to define OSTypes for keys, classes,
// enumeration types, and enumeration values. It exists only for backward
// compatibility. 
//
// Add names of new events, keys, classes, enum types and enum values to
// PIStringTerminology.h
//
// The aete resource, which referenced these keys, IS BEING
// DELETED. A Pate resource is being used instead (see UActionsTerminology.r
// for the format). This resource identifies items with strings instead
// of OSTypes. New APIs support construction and
// access of descriptors with strings instead of OSTypes. If you need to
// find the string equivalent of an OSType from this table, you can look
// in UActions.cpp. If you need to look it up the string corresponding to
// an ID at runtime inside the app, you can use:
// charPtr = GetStringIDMap ()->Find (DescType)
// From a plugin, use StringIDToTypeID in the ActionControlSuite or the
// BasicActionControlSuite
//
// The symbols in this file are still needed for forms, types, and units,
// and so that existing code which references them will still work. But 
// NEW CODE SHOULD USE THE STRING-BASED APIs and define the string constants
// in PIStringTerminology.h

Photo of Jaroslav Bereza

Jaroslav Bereza

  • 779 Posts
  • 166 Reply Likes
Yes in SDK are long lists of StringIDs and CharIDs and even some notes where one charID has multiple different stringIDs. But according to my observations, there is not everything.

If I understand that comment means... "programmers don't use charIDs and use stringIDs instead (c++)"