• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Pls. help . . .Photoshop... Auto Select the layers above the layer ( Scripts )

Participant ,
May 29, 2024 May 29, 2024

Copy link to clipboard

Copied

Hi All ... pls help me

Can you help me with scripts that will automatically select all layers above the selected layer when running the script?scripts.jpg

TOPICS
macOS , Windows

Views

109

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , May 29, 2024 May 29, 2024

Myra has provided a hint for automation... This can be done for all visible layers above the current layer via two keyboard shortcuts and or in an action:

 

ALT/OPT + ]

ALT/OPT + SHIFT + .

 

image.png

There are better ways, however, the ScriptingListener ExtendScript code for these two action steps:

 

// Select forward visible layer
var s2t = function (s) {
	return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var list = new ActionList();
...

Votes

Translate

Translate
Community Expert , May 30, 2024 May 30, 2024
quote

Thank you very much, sir @Stephen_A_Marsh . . . Alt+Shift+. I didn't know you could use that shortcut


By @Thiha31203570tbl0

 

You're welcome, it's two separate keyboard shortcuts combined:

 

Select/target front (top) layer =  Option +

Add to continuous selection =  Shift

 

Selecting layers via the mouse captures their absolute name in the action, which isn't useful when running the action on other images with different layer names. Recording the action with keyboard shortcuts doesn't have t

...

Votes

Translate

Translate
Adobe
Community Expert ,
May 29, 2024 May 29, 2024

Copy link to clipboard

Copied

I don't have a script for you, but because the layers you want selected are contiguous, you can select them by selecting the bottom layer of what you want, holding down Shift, and selecting the top layer that you want.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 29, 2024 May 29, 2024

Copy link to clipboard

Copied

Myra has provided a hint for automation... This can be done for all visible layers above the current layer via two keyboard shortcuts and or in an action:

 

ALT/OPT + ]

ALT/OPT + SHIFT + .

 

image.png

There are better ways, however, the ScriptingListener ExtendScript code for these two action steps:

 

// Select forward visible layer
var s2t = function (s) {
	return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var list = new ActionList();
var list2 = new ActionList();
var reference = new ActionReference();
var reference2 = new ActionReference();
reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "forwardEnum" ));
descriptor.putReference( s2t( "null" ), reference );
descriptor.putBoolean( s2t( "makeVisible" ), false );
list.putInteger( 4 );
descriptor.putList( s2t( "layerID" ), list );
executeAction(s2t( "select" ), descriptor, DialogModes.NO);
// Add continuous visible layers to front layer
reference2.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "front" ));
descriptor2.putReference( s2t( "null" ), reference2 );
descriptor2.putEnumerated( s2t( "selectionModifier" ), s2t( "selectionModifierType" ), s2t( "addToSelectionContinuous" ));
descriptor2.putBoolean( s2t( "makeVisible" ), false );
descriptor2.putList( s2t( "layerID" ), list2 );
executeAction( s2t( "select" ), descriptor2, DialogModes.NO );

 

P.S. Further steps could be added to the action or script to correctly handle invisible layers.

 

EDIT: The following code will select all visible or invisible layers above the active layer:

 

// Toggle visibility of active layer
var s2t = function (s) {
	return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var list = new ActionList();
var reference = new ActionReference();
reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
list.putReference( reference );
descriptor.putList( s2t( "null" ), list );
descriptor.putBoolean( s2t( "toggleOptionsPalette" ), true );
executeAction(s2t("show"), descriptor, DialogModes.NO);

// Select forward layer
var s2t = function (s) {
	return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var list = new ActionList();
var reference = new ActionReference();
reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "forwardEnum" ));
descriptor.putReference( s2t( "null" ), reference );
descriptor.putBoolean( s2t( "makeVisible" ), false );
list.putInteger( 4 );
descriptor.putList( s2t( "layerID" ), list );
executeAction(s2t( "select" ), descriptor, DialogModes.NO);

// Get the active layer name
var theLayerName = app.activeDocument.activeLayer.name;

// Add continuous visible layers to front layer
var s2t = function (s) {
	return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var list = new ActionList();
var reference = new ActionReference();
reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "front" ));
descriptor.putReference( s2t( "null" ), reference );
descriptor.putEnumerated( s2t( "selectionModifier" ), s2t( "selectionModifierType" ), s2t( "addToSelectionContinuous" ));
descriptor.putBoolean( s2t( "makeVisible" ), false );
descriptor.putList( s2t( "layerID" ), list );
executeAction(s2t( "select" ), descriptor, DialogModes.NO);

// Toggle the visibility of the base selected layer
var s2t = function (s) {
	return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var list = new ActionList();
var reference = new ActionReference();
reference.putName( s2t( "layer" ), theLayerName );
list.putReference( reference );
descriptor.putList( s2t( "null" ), list );
descriptor.putBoolean( s2t( "toggleOptionsPalette" ), true );
executeAction(s2t( "show" ), descriptor, DialogModes.NO);

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 30, 2024 May 30, 2024

Copy link to clipboard

Copied

Thank you very much, sir @Stephen_A_Marsh . . . Alt+Shift+. I didn't know you could use that shortcut

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 30, 2024 May 30, 2024

Copy link to clipboard

Copied

quote

Thank you very much, sir @Stephen_A_Marsh . . . Alt+Shift+. I didn't know you could use that shortcut


By @Thiha31203570tbl0

 

You're welcome, it's two separate keyboard shortcuts combined:

 

Select/target front (top) layer =  Option +

Add to continuous selection =  Shift

 

Selecting layers via the mouse captures their absolute name in the action, which isn't useful when running the action on other images with different layer names. Recording the action with keyboard shortcuts doesn't have this limitation.

 

Relative Layer Keycuts:

 

Select/target front (top) layer =  Option + .
Select/target next layer up =  Option ]
Select/target next layer down =  Option [
Select/target back (bottom) layer =  Option ,

Move current target layer to front (top) layer =  Command Shift ]
Move current target layer up =  Command ]
Move current target layer down =  Command [
Move current target layer to back (bottom) layer =  Command Shift [

Windows users would swap the Command key for Ctrl and the Option key for Alt

 

Keep in mind that these keyboard-shortcuts are affected by layer visibility, one has to use extra steps to deal with invisible layers, such as:

 

Stephen_A_Marsh_0-1714691253869.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 31, 2024 May 31, 2024

Copy link to clipboard

Copied

LATEST

Thank you so much sir @Stephen_A_Marsh  . . . 

This helped me a lot

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines