Skip to main content
MrWobbles
Participant
March 6, 2022
Answered

Choose a layer and make it a selection

  • March 6, 2022
  • 1 reply
  • 1197 views

Mac os 10.14.6; Photoshop CC 2018 (release 19.1.3)

 

Right-clicking on an image opens a context menu from which I can choose the layer. If I then want to make that layer a selection, I need to navigate to the layer palette and left click on that layer. Not a big deal, except I have to stop another action, do these two steps manually, then continues the action --- and do it many, many times.

 

Is there any way to combine the right-click step (choose the layer) then make it a selection steps into an action? 

This topic has been closed for replies.
Correct answer jazz-y

As this is more about a smooth workflow, I can't think of anything built-in that would not be more pain than it was worth...

 

So it is probably best to just record a single step action with a F-Key shortcut to load the active layer's transparency as a selection. That way you can just press the shortcut key after selecting the layer.

 

If the F-Key combo is a little painful, this could be scripted and scripts can have "normal" keyboard shortcuts applied (not F-key based):

 

 

// Load selection from active layer transparency
#target photoshop
loadLayerTrans();
function loadLayerTrans() {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();
	var reference2 = new ActionReference();
	reference.putProperty(s2t("channel"), s2t("selection"));
	descriptor.putReference(s2t("null"), reference);
	reference2.putEnumerated(s2t("channel"), s2t("channel"), s2t("transparencyEnum"));
	descriptor.putReference(s2t("to"), reference2);
	executeAction(s2t("set"), descriptor, DialogModes.NO);
}

 

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 


We can improve this scenario a bit by listening to the layer select event. To make the logic of selecting the transparency of a layer from the menu look like a selection on the palette, you also need to hold down cmd (or ctrl) when the menu item is activated:

 

#target photoshop
var s2t = stringIDToTypeID,
    t2s = typeIDToStringID;
try {
    var target = t2s(arguments[0].getReference(s2t('null')).getDesiredClass());
    if (target == 'layer' && (ScriptUI.environment.keyboardState.ctrlKey || ScriptUI.environment.keyboardState.metaKey)) {
        (r = new ActionReference()).putProperty(s2t('channel'), s2t('selection'));
        (d = new ActionDescriptor()).putReference(s2t('null'), r);
        (r1 = new ActionReference()).putEnumerated(s2t('channel'), s2t('channel'), s2t('transparencyEnum'));
        d.putReference(s2t('to'), r1);
        executeAction(s2t('set'), d, DialogModes.NO);
    }
} catch (e) { }
if (!target) {
    app.notifiersEnabled = true
    var f = File($.fileName),
        deleted;
    for (var i = 0; i < app.notifiers.length; i++) {
        var ntf = app.notifiers[i]
        if (ntf.eventFile.name == f.name) { ntf.remove(); i--; deleted = true }
    }
    if (deleted) {
        alert('event listening disabled!')
    } else {
        app.notifiers.add('slct', f, 'Lyr ')
        alert('event listening enabled!')
    }
}

 

* I can't test it on macOS at the moment, but it should work.
** tested on Big Sur 11.6.4 - it works.

1 reply

Stephen Marsh
Community Expert
Community Expert
March 6, 2022

Just to confirm, do you have the move tool active to bring up the contextual layer selection menu?

 

Do you mean left CMD/CTRL click on the layer to load the layer transparency as a selection?

 

Unless the action has a stop step or modal active, the action is designed to play from beginning to end. If I am understanding you correctly, you would like a step in the action to dynamically allow the loading of a selection from a target layer without interrupting the flow of the action. Is that correct?

 

MrWobbles
MrWobblesAuthor
Participant
March 7, 2022

Thank you so much for responding.

Holding down the Apple command key activates the move tool momentarily. Then right-clicking on the image opens the drop down menu, and I can choose the layer I want in the Layers Palette from the menu.

The another hold (to continue holding) on the Apple command key enables me to click on the chosen layer in the Layers palette, and load it as a selection (marching ants).

And “yes” to your description of what I am hoping to do.
Michael Sohns

 

[Personal info removed by moderator.]

 

 

 

jazz-yCorrect answer
Legend
March 8, 2022

As this is more about a smooth workflow, I can't think of anything built-in that would not be more pain than it was worth...

 

So it is probably best to just record a single step action with a F-Key shortcut to load the active layer's transparency as a selection. That way you can just press the shortcut key after selecting the layer.

 

If the F-Key combo is a little painful, this could be scripted and scripts can have "normal" keyboard shortcuts applied (not F-key based):

 

 

// Load selection from active layer transparency
#target photoshop
loadLayerTrans();
function loadLayerTrans() {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();
	var reference2 = new ActionReference();
	reference.putProperty(s2t("channel"), s2t("selection"));
	descriptor.putReference(s2t("null"), reference);
	reference2.putEnumerated(s2t("channel"), s2t("channel"), s2t("transparencyEnum"));
	descriptor.putReference(s2t("to"), reference2);
	executeAction(s2t("set"), descriptor, DialogModes.NO);
}

 

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 


We can improve this scenario a bit by listening to the layer select event. To make the logic of selecting the transparency of a layer from the menu look like a selection on the palette, you also need to hold down cmd (or ctrl) when the menu item is activated:

 

#target photoshop
var s2t = stringIDToTypeID,
    t2s = typeIDToStringID;
try {
    var target = t2s(arguments[0].getReference(s2t('null')).getDesiredClass());
    if (target == 'layer' && (ScriptUI.environment.keyboardState.ctrlKey || ScriptUI.environment.keyboardState.metaKey)) {
        (r = new ActionReference()).putProperty(s2t('channel'), s2t('selection'));
        (d = new ActionDescriptor()).putReference(s2t('null'), r);
        (r1 = new ActionReference()).putEnumerated(s2t('channel'), s2t('channel'), s2t('transparencyEnum'));
        d.putReference(s2t('to'), r1);
        executeAction(s2t('set'), d, DialogModes.NO);
    }
} catch (e) { }
if (!target) {
    app.notifiersEnabled = true
    var f = File($.fileName),
        deleted;
    for (var i = 0; i < app.notifiers.length; i++) {
        var ntf = app.notifiers[i]
        if (ntf.eventFile.name == f.name) { ntf.remove(); i--; deleted = true }
    }
    if (deleted) {
        alert('event listening disabled!')
    } else {
        app.notifiers.add('slct', f, 'Lyr ')
        alert('event listening enabled!')
    }
}

 

* I can't test it on macOS at the moment, but it should work.
** tested on Big Sur 11.6.4 - it works.