2

I'm looking to find the settings for various options for different tools in Photoshop.

This post hinted at the answer: https://graphicdesign.stackexchange.com/a/113421

It said:

To get a current setting of an eyedropper (switch to eyedropper first using Joonas' selectTool()):

//returns 0 for Point Sample, 1 for 3x3, etc
function getCurrentEyedropperSetting() {
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("tool"));
ref.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
return executeActionGet(ref).getObjectValue(stringIDToTypeID("currentToolOptions")).getInteger(stringIDToTypeID("eyeDropperSample"));
};

But how would one know the correct stringID ("eyeDropperSample" in this case) for a certain tool option in order to extract its value?

For example, I'm looking to get the "Range" setting of the Burn tool. I've selected my Burn tool and tried replacing "eyeDropperSample" with:

"range"

"burnRange"

"burnToolRange"

And they all result in execution errors for the script.

ScriptListener doesn't provide any clue as to what the correct StringID would be either as changing the mode doesn't generate any entry in ScriptListener.

Sort of a mystery to me at this point. Is there a list of StringIDs somewhere that I could search through to find the correct one for the Burn tool Range? Or is there a way to get Photoshop to tell me the correct StringID?

  • No the system isnt very well planned – joojaa Aug 31 '18 at 13:26
  • Well, I did find the following TypeID/StringID pairs that seem to be related to the ranges for the Burn Tool: "'BrnH'": "burnInH". "'BrnM'": "burnInM", "'BrnS'": "burnInS", But I'm not able to extract any information as to their values, boolean or otherwise, so far. – Arcturus Aug 31 '18 at 16:41
  • Well you can often find hints in the C api manual. But more often than not you will just fail to get further at some point for no reason – joojaa Aug 31 '18 at 16:53
  • Thanks for the info. By trial and error I ended up using "getClass()" to figure out the class for "mode" and once I had that, everything fell into place. So I ended up not trying the solutions offered here, but really appreciate them and have a feeling they will be very helpful to others. – Arcturus Sep 2 '18 at 0:28
1

I'm using this snippet by Mike Hale. It outputs to the ExtendScript Toolkit debug window all the found descriptors in the specific class and property (tool, in this instance)

function getDescriptor(psClass, psKey) {
    var ref;
    ref = new ActionReference();
    if (psKey != undefined) ref.putProperty(charIDToTypeID("Prpr"), psKey);
    ref.putEnumerated(psClass, charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
    return psKey != undefined ? executeActionGet(ref).getObjectValue(psKey) : executeActionGet(ref);
};

var desc = getDescriptor(stringIDToTypeID("application"), stringIDToTypeID("tool"))

if (desc.typename == 'ActionReference') {
    var c = desc.count;
    for (var i = 0; i < c; i++) { //enumerate reference. use getForm() to determine which get method to use
        $.writeln('Key ' + zeroPad(i + 1, 2) + ' = ' + desc.getReference(i).getIndex());
    }
}

if (desc.typename == 'ActionList') {
    var c = desc.count;
    for (var i = 0; i < c; i++) { //enumerate list
        $.writeln('Key ' + zeroPad(i + 1, 2) + ' = ' + desc.getType(i))
    }
}
if (desc.typename == 'ActionDescriptor') {
    var c = desc.count;
    for (var i = 0; i < c; i++) { //enumerate descriptor's keys
        $.writeln('Key ' + zeroPad(i + 1, 2) + ' = ' + IDTz(desc.getKey(i)) + ' : ' + desc.getType(desc.getKey(i)))
    }
}

function IDTz(id) {
    var isCharID = false;
    try {
        if (new String(id).length == 10) {
            isCharID = true;
            var charID = '"' + typeIDToCharID(id) + '"';
            var stringID = '"' + typeIDToStringID(id) + '"';
            if (stringID.length <= 2) {
                stringID = '  NA   ';
            } else {
                while (stringID.length < 25) {
                    stringID += ' ';
                }
            }
        } else {
            var charID = ' NA  ';
            var stringID = '"' + typeIDToStringID(id) + '"';
            while (stringID.length < 25) {
                stringID += ' ';
            }
        }
    } catch (e) {}
    return charID + ' | ' + stringID;
}

function zeroPad(num, pad) {
    var z = Math.pow(10, Number(pad))
    return num <= z ? ((Number(num) + z).toString().substr(1)) : num
}

function getDescValue( theDesc, descType, position ) {    
    switch( descType ) {  
        case 'DescValueType.BOOLEANTYPE':  
            return theDesc.getBoolean( position );  
            break;

        case 'DescValueType.CLASSTYPE':  
            return theDesc.getClass( position );  
            break;

        case 'DescValueType.DOUBLETYPE':  
            return theDesc.getDouble( position );  
            break;

        case 'DescValueType.ENUMERATEDTYPE':  
            return typeIDToStringID(theDesc.getEnumerationValue( position ));  
            break;

        case 'DescValueType.INTEGERTYPE':  
            return theDesc.getInteger( position );  
            break;

        case 'DescValueType.LISTTYPE':  
            return theDesc.getList( position );  
            break;

        case 'DescValueType.OBJECTTYPE':
            return theDesc.getObjectValue( position );  
            break;

        case 'DescValueType.REFERENCETYPE':
            return theDesc.getReference( position );  
            break;

        case 'DescValueType.STRINGTYPE':
            var str = '';
            return str + theDesc.getString( position );  
            break;

        case 'DescValueType.UNITDOUBLE':  
            return theDesc.getUnitDoubleValue( position );  
            break;        

        case 'DescValueType.ALIASTYPE':  
            return decodeURI(theDesc.getPath( position ));
            break;

        case 'DescValueType.RAWTYPE':  
            return theDesc.getData( position );
            break;

        default:
            break;  
    };
};
  • Is there a way to read and set the options in History Options (Hamburger menu of the History Panel)? – Royi Apr 3 at 20:16
0

It is enum with string key "mode" You can use my tool for reading descriptors...

Otherwise you need to..

  1. get number of keys in action descriptor .count
  2. loop all keys and their names .getKey(index)
  3. it returns typeID so you have to use charIDToTypeID() or stringIDToTypeID() and now you should know name of properties inside descriptor
  4. then you can use .getType(typeID) and it returns what data type the property is
  5. And finally you can decide if you will use getString() or getEnumerationValue() or another data type method

https://github.com/jardicc/ActionManagerHumanizer

#include Humanizer.jsx
...
var descriptorContent = Humanizer.descriptorToObject(executeActionGet(ref));

enter image description here

Blend mode enums. Some tools/actions might use only specific enums.

enter image description here

  • Is there a way to read and set the options in History Options (Hamburger menu of the History Panel)? – Royi Apr 3 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.