Skip to main content
Inspiring
November 9, 2023
Question

Action Manager Update

  • November 9, 2023
  • 4 replies
  • 3118 views

I came across this post of GDSE and now, it nearly being the end of 2023, can anyone confirm or deny if this (unsourced) statement "...Action manager won't be supported in newer versions of Photoshop." is true or not??

 

Is this a random rumour? Or is it anything that Action Manager coding fans should be concerned about? Clarity with an  explantion is due.

 

The truth is out there with a side order of cookies...

 

 

This topic has been closed for replies.

4 replies

c.pfaffenbichler
Community Expert
Community Expert
January 12, 2024

@DavideBarranca , please forgive the intrusion, but could you clear up this query? 

Davide_Barranca12040269
Legend
January 12, 2024

For AM to be unsupported, the whole ExtendScript language should be dropped, which I doubt will happen anytime soon. I have no insider information to share, but my sense is that we might enjoy a few years of backward compatibility with the old system.
OTH, AM like a phoenix is now found in ActionJSON (also known as BatchPlay), in the context of UXP scripting (and UXP plugins). Same exact stuff, different (easier) syntax.
Shameless plug: I've published a new book on the UXP Photoshop API titled "Professional Photoshop UXP", which covers (also, and in great depth) exactly that topic.

Hope this helps!

 

—Davide Barranca

Davide Barranca - PS developer and authorwww.ps-scripting.com
Legend
January 17, 2024

sorry for the question but now how do you program, do you use actions do you use javascript or what


A combination of Extendscript, Action Manager, and Actions usually.

This is the script I use to implement the above image, starting with no text overlay and ending with a finished, saved PSD and JPEG. Weight saved to dc:description and vendor part number (second line) saved to Photoshop:transmissionReference. The actions align the text layer, save a PSD, and Save for Web. Please feel free to laugh at how bad this code is LOL

#target photoshop
testText();
function testText(){
    if(documents.length > 0){
        var originalDialogMode = app.displayDialogs;
        app.displayDialogs = DialogModes.ERROR;
        var originalRulerUnits = preferences.rulerUnits;
        preferences.rulerUnits = Units.PIXELS;
        var docRef = app.activeDocument;
        var fileNameNoExtension = docRef.name;
        //text formatting
        var size1 = 96;
        var size2 = 60;
        var size3 = 54;
        var size4 = 42;
        var font1 = 'Calibri';
        var font2 = 'Calibri';
        var style1 = 'Bold';
        var style2 = 'Regular';
        var texth = 220;
        var textw = 660;
        try{
            var vendorItem = '';
            var itemWeight = '';
            var newText = '';
            var LayerRef = null;
            var TextRef = null;
            if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
            var xmp = new XMPMeta(docRef.xmpMetadata.rawData);
            for(var x = 0; x < documents.length; x++){
                activeDocument = documents[x];
                docRef = documents[x];
                fileNameNoExtension = docRef.name;
                vendorItem = '';
                itemWeight = '';
                newText = '';
                LayerRef = null;
                TextRef = null;
                xmp = new XMPMeta(docRef.xmpMetadata.rawData);
                if(xmp.doesPropertyExist(XMPConst.NS_DC, 'description')){
                    itemWeight = xmp.getLocalizedText(XMPConst.NS_DC, 'description', null, 'x-default');
                    docRef.info.headline = itemWeight.toString();
                    }
                if(xmp.doesPropertyExist(XMPConst.NS_PHOTOSHOP, 'TransmissionReference')){
                    vendorItem = xmp.getProperty(XMPConst.NS_PHOTOSHOP, 'TransmissionReference').toString();
                    }
                if(itemWeight == null){
                    preferences.rulerUnits = originalRulerUnits;
                    app.displayDialogs = originalDialogMode;
                    return;
                    }
                vendorItem = vendorItem.toUpperCase();
                preferences.rulerUnits = Units.PIXELS;
                for(var i = 0; i < docRef.artLayers.length; i++){
                    if(docRef.artLayers[i].kind == LayerKind.TEXT){
                        docRef.artLayers[i].remove();
                        }
                    }
                fileNameNoExtension = docRef.name;
                fileNameNoExtension = fileNameNoExtension.split('-');
                if(fileNameNoExtension.length > 1){
                    fileNameNoExtension.length--;
                    }
                fileNameNoExtension = fileNameNoExtension.join('-');
                fileNameNoExtension = fileNameNoExtension.split('.');
                if(fileNameNoExtension.length > 1){
                    fileNameNoExtension.length--;
                    }
                fileNameNoExtension = fileNameNoExtension.join('.');
                if(vendorItem == ''){
                    newText = fileNameNoExtension;
                    }
                else{
                    newText = fileNameNoExtension + '\r(' + vendorItem + ')';
                    }
                if((docRef.name.search('-front') != -1) || (docRef.name.search('-back') != -1)){
                    if(fileNameNoExtension.length > 6){
                        app.doAction('2000','EGP');
                        }
                    else{
                        app.doAction('1800','EGP');
                        }
                    }
                LayerRef = docRef.artLayers.add();
                LayerRef.kind = LayerKind.TEXT;
                TextRef = LayerRef.textItem;
                TextRef.kind = TextType.PARAGRAPHTEXT;
                TextRef.contents = newText + '\rShipping Weight: ' + itemWeight;
                TextRef.position = new Array(425, 425);
                preferences.rulerUnits = Units.POINTS;
                TextRef.size = size1;
                TextRef.useAutoLeading = false;
                TextRef.leading = size4;
                TextRef.font = font1;
                TextRef.style = style1;
                TextRef.justification = Justification.CENTER;
                TextRef.autoKerning = AutoKernType.METRICS;
                layerUpdate();
                function setFormatting(start, end, fontName, fontStyle, fontSize){ //format text per input
                    var idsetd = app.charIDToTypeID('setd');
                    var action = new ActionDescriptor();
                    var idnull = app.charIDToTypeID('null');
                    var reference = new ActionReference();
                    var idTxLr = app.charIDToTypeID('TxLr');
                    var idOrdn = app.charIDToTypeID('Ordn');
                    var idTrgt = app.charIDToTypeID('Trgt');
                    reference.putEnumerated(idTxLr, idOrdn, idTrgt);
                    action.putReference(idnull, reference);
                    var idT = app.charIDToTypeID('T   ');
                    var textAction = new ActionDescriptor();
                    var idTxtt = app.charIDToTypeID('Txtt');
                    var actionList = new ActionList();
                    var textRange = new ActionDescriptor();
                    var idFrom = app.charIDToTypeID('From');
                    textRange.putInteger(idFrom, start);
                    textRange.putInteger(idT, end);
                    var idTxtS = app.charIDToTypeID('TxtS');
                    var formatting = new ActionDescriptor();
                    var idFntN = app.charIDToTypeID('FntN');
                    formatting.putString(idFntN, fontName);
                    var idFntS = app.charIDToTypeID('FntS');
                    formatting.putString(idFntS, fontStyle);
                    var idSz = app.charIDToTypeID('Sz  ');
                    var idPnt = app.charIDToTypeID('#Pnt');
                    formatting.putUnitDouble(idSz, idPnt, fontSize);
                    textRange.putObject(idTxtS, idTxtS, formatting);
                    actionList.putObject(idTxtt, textRange);
                    textAction.putList(idTxtt, actionList);
                    action.putObject(idT, idTxLr, textAction);
                    app.executeAction(idsetd, action, DialogModes.NO);
                    }
                function layerUpdate(){
                    try{
                        preferences.rulerUnits = Units.POINTS;
                        TextRef.textComposer = TextComposer.ADOBESINGLELINE;
                        if(TextRef.size == size1){
                            TextRef.size = size4;
                            TextRef.font = font2;
                            TextRef.style = style2;
                            TextRef.useAutoLeading = false;
                            TextRef.leading = size4;
                            var l = TextRef.contents.split(/\r/);
                            setFormatting(0, l[0].length, font1, style1, size1);
                            var textFragmentLen = l[0].length + l[1].length + 1;
                            if(l.length > 2){
                                setFormatting(textFragmentLen, (textFragmentLen + l[2].length -8), font1, style1, size4);
                                }
                            else{
                                var sectextFragmentLen = l[1].split(':');
                                setFormatting((textFragmentLen - l[1].length), l[0].length + sectextFragmentLen[0].length + 2, font1, style1, size4);
                                }
                            preferences.rulerUnits = Units.PIXELS;
                            if(TextRef.kind == TextType.PARAGRAPHTEXT){
                                TextRef.height = texth;
                                TextRef.width = textw;
                                TextRef.useAutoLeading = false;
                                TextRef.leading = size4;
                                }
                            app.doAction('Align title', 'EGP');
                            app.doAction('Save', 'EGP');
                            app.doAction('SFW', 'EGP');
                            }
                        }
                    catch(e){
                        alert(e + '  ' + e.line);
                        return;
                        }
                    }
                }
            }
        catch(e){
            preferences.rulerUnits = originalRulerUnits;
            app.displayDialogs = originalDialogMode;
            return;
            }
        preferences.rulerUnits = originalRulerUnits;
        app.displayDialogs = originalDialogMode;
        }
    else{
        alert('You must have a document open to run this script.');
        return;
        }
    }

 

c.pfaffenbichler
Community Expert
Community Expert
January 12, 2024

If I understood correctly then its not AM-code in particular, but ESTK Scripting altogether that is on »legacy«-staus and will, at some unkown point in the future, be removed altogether, thus forcing the switch to UXP Scripting. 

Legend
January 12, 2024

And then things will get ugly.

c.pfaffenbichler
Community Expert
Community Expert
January 12, 2024

»Adobe giveth and Adobe taketh …«

 

But like I said: »If I understood correctly«

I am not sure where exactly I read about this, so I might be mistaken and the timeline had not been published anyway. 

It might be a couple of versions off even if it ultimately happens. 

Inspiring
January 12, 2024

Two months and yet no response or further clarification.

 

Inspiring
November 9, 2023

+1 from me too, can we get some clarity?