Photoshop: I can't record "Select all layers" in script listener and in actions

  • 1
  • Problem
  • Updated 2 years ago
  • (Edited)
I can't record "Sellect all layers" in script listener and in actions.
Great command, but I can't record it.
Photo of Jaroslav Bereza

Jaroslav Bereza

  • 779 Posts
  • 166 Reply Likes
  • sad

Posted 2 years ago

  • 1
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 813 Reply Likes
Actions does record the Select -> All Layers command, and it plays back correctly.
I don't have Script Listener installed right now, so I can't test that.

But this works

cTID = function(s) { return cTID[s] || (cTID[s] = app.charIDToTypeID(s)); };

function selectAllLayers() {
    var ref = new ActionReference();
    ref.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
    var desc = new ActionDescriptor();
    desc.putReference(cTID('null'), ref);
    executeAction(sTID('selectAllLayers'), desc, DialogModes.NO);
}
Photo of Jaroslav Bereza

Jaroslav Bereza

  • 779 Posts
  • 166 Reply Likes
Thanks very much.

If I add "sTID" then it works nice :-)
So my code is:
cTID = function(s) { return cTID[s] || (cTID[s] = app.charIDToTypeID(s)); };
sTID = function(s) { return app.stringIDToTypeID(s); }; 

selectAllLayers();
function selectAllLayers() {
    var ref = new ActionReference();
    ref.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
    var desc = new ActionDescriptor();
    desc.putReference(cTID('null'), ref);
    executeAction(sTID('selectAllLayers'), desc, DialogModes.NO);
}
I can record the command in action panel only if I select "insert menu item" http://insightandinsanity.com/photoshop-actions-quick-tip-insert-menu-item/

And finally this will generate code in script listener. But otherwise without "insert menu item" it's not in script listener.

Generated code
var idselectAllLayers = stringIDToTypeID( "selectAllLayers" );
    var desc1247 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref805 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref805.putEnumerated( idLyr, idOrdn, idTrgt );
    desc1247.putReference( idnull, ref805 );
executeAction( idselectAllLayers, desc1247, DialogModes.NO );
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 813 Reply Likes
Oops, forgot to copy that sTID function, sorry.
But the select all layers command seems to be recording and playing back just fine for all my systems.
Photo of Jeffrey Tranberry

Jeffrey Tranberry, Sr. Product Manager, Digital Imaging

  • 14147 Posts
  • 1765 Reply Likes
What version of PS are you running? I seem to remember a past update having issues with this but CC 2015.1.2 both records and plays back the following listener code:

var idselectAllLayers = stringIDToTypeID( "selectAllLayers" );
    var desc36 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref24 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref24.putEnumerated( idLyr, idOrdn, idTrgt );
    desc36.putReference( idnull, ref24 );
executeAction( idselectAllLayers, desc36, DialogModes.NO );
Photo of Jaroslav Bereza

Jaroslav Bereza

  • 779 Posts
  • 166 Reply Likes
I found new UI bug... I can't see version number in dialog
http://sklad.bereza.cz/00-jarda/00_screenshot/2016-03-30_183117.jpg
(dialog is ok on my primary monitor, secondary is on screenshot)

I have 2015.1.2

Is there posibility to have bad/old listener plugin?
Photo of Jaroslav Bereza

Jaroslav Bereza

  • 779 Posts
  • 166 Reply Likes
"Select no layers" also doesn't work. But I think... I seen it in Script Listener, but I can't reproduce it without workaround with action panel.
(Edited)
Photo of Jaroslav Bereza

Jaroslav Bereza

  • 779 Posts
  • 166 Reply Likes
I restarted ExtendScript Toolkit and now it works good.