Select All Pixels on a Layer PhotoShop CC

I want to be able to select all pixels on a layer in PhotoShop CC 2015.5. I use to be able to use…


tell application "Adobe Photoshop CC 2015.5"
tell current document
set current layer to layer "ThisLayer"
select all
translate layer "ThisLayer" delta x 0 delta y 0
end tell
end tell

This use to select all pixels with a marquee around everything.

I’m looking for an applescript command that would do the same as if I Command clicked on a layer thumbnail.

You can use this Javascript:


set layerName to "ThisLayer"

tell application id "com.adobe.Photoshop"
	tell current document
		do javascript "var idsetd = charIDToTypeID( \"setd\" );    var desc11 = new ActionDescriptor();    var idnull = charIDToTypeID( \"null\" );        var ref15 = new ActionReference();        var idChnl = charIDToTypeID( \"Chnl\" );        var idfsel = charIDToTypeID( \"fsel\" );        ref15.putProperty( idChnl, idfsel );    desc11.putReference( idnull, ref15 );    var idT = charIDToTypeID( \"T   \" );        var ref16 = new ActionReference();        var idChnl = charIDToTypeID( \"Chnl\" );        var idChnl = charIDToTypeID( \"Chnl\" );        var idTrsp = charIDToTypeID( \"Trsp\" );        ref16.putEnumerated( idChnl, idChnl, idTrsp );        var idLyr = charIDToTypeID( \"Lyr \" );        ref16.putName( idLyr, \"" & layerName & "\" );    desc11.putReference( idT, ref16 );executeAction( idsetd, desc11, DialogModes.NO );"
	end tell
end tell

Wow, that’s a lot of code to make a simple selection. Tried it but it errors. Anyone have a simple applescript way to select all pixels on a layer?

You could toggle the visibility of unwanted layers and then load the selection from either a channel composite or multiple channels or you could record an Action and use a script as a trigger; it may be easiest to use the latter method, especially if any antialiasing is present.

No problems here, please try again with this Script:


set layerName to "ThisLayer"

tell application id "com.adobe.Photoshop"
	tell current document
		do javascript "var idsetd = charIDToTypeID( \"setd\" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( \"null\" );
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID( \"Chnl\" );
        var idfsel = charIDToTypeID( \"fsel\" );
        ref2.putProperty( idChnl, idfsel );
    desc3.putReference( idnull, ref2 );
    var idT = charIDToTypeID( \"T   \" );
        var ref3 = new ActionReference();
        var idChnl = charIDToTypeID( \"Chnl\" );
        var idChnl = charIDToTypeID( \"Chnl\" );
        var idTrsp = charIDToTypeID( \"Trsp\" );
        ref3.putEnumerated( idChnl, idChnl, idTrsp );
        var idLyr = charIDToTypeID( \"Lyr \" );
        ref3.putName( idLyr, \"" & layerName & "\" );
    desc3.putReference( idT, ref3 );
executeAction( idsetd, desc3, DialogModes.NO );"
	end tell
end tell

If you install Adobe’s ‘ScriptingListener.plugin’ here,
/Applications/Adobe Photoshop CC 2015.5/Plug-ins/Utilities/ScriptingListener.plugin
Photoshop stores every action as JavaScript in a Textfile on your desktop ‘ScriptingListenerJS.log’.

It’s very useful because not every Photoshop action is available from AppleScript.

https://forums.adobe.com/thread/1237032

Ah, there is a problem with pasting code here between the AppleScript-Tags. Seems that this forum trims spaces.

In this line:
var idT = charIDToTypeID( "T " );

there must be 3 spaces after the char ‘T’.

Please try.