Last active
December 20, 2019 20:54
-
-
Save joonaspaakko/1e729111b8bbd8c2cde038bac588aadd to your computer and use it in GitHub Desktop.
Photoshop script for selecting all layers, including the background layer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
selectAllLayers(); | |
function selectAllLayers() { | |
// Select all layers (doesn't include Background) | |
try { | |
var desc = new ActionDescriptor(); | |
var ref = new ActionReference(); | |
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); | |
desc.putReference( charIDToTypeID('null'), ref ); | |
executeAction( stringIDToTypeID('selectAllLayers'), desc, DialogModes.NO ); | |
} catch(e) {} | |
// Add Background Layer to the selection (if possible) | |
try { | |
activeDocument.backgroundLayer; | |
var bgID = activeDocument.backgroundLayer.id; | |
var ref = new ActionReference(); | |
var desc = new ActionDescriptor(); | |
ref.putIdentifier(charIDToTypeID('Lyr '), bgID); | |
desc.putReference(charIDToTypeID('null'), ref); | |
desc.putEnumerated( stringIDToTypeID('selectionModifier'), stringIDToTypeID('selectionModifierType'), stringIDToTypeID('addToSelection') ); | |
desc.putBoolean(charIDToTypeID('MkVs'), false); | |
executeAction(charIDToTypeID('slct'), desc, DialogModes.NO); | |
} catch(e) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment