Copy link to clipboard
Copied
If you click outside of the open document, then on the layers' panel untagged about which layer is active, some are blocked by filters, but in the properties of the active layer of a document. In his instrument I want to also block some of the controls in case you explicitly select one of the layers (not marked in the layers' panel)
This will give you a list of selected layers, the array will be zero if no layers are selected.
...var selectedLayer = getSelectedLayersIdx();
if(!selectedLayer.length) alert("no layers selected");
function getSelectedLayersIdx(){
var selectedLayers = new Array;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
if( desc.hasKey( stringIDToTypeID( 'targetLayers' )
Copy link to clipboard
Copied
I don’t seem to understand what you are asking.
Could you please elaborate, mabe provide screenshots or sketches to illustrate the issue?
Copy link to clipboard
Copied
jn this video you can see what menu Filters are blkcked if no layer is selected.
Copy link to clipboard
Copied
This will give you a list of selected layers, the array will be zero if no layers are selected.
var selectedLayer = getSelectedLayersIdx();
if(!selectedLayer.length) alert("no layers selected");
function getSelectedLayersIdx(){
var selectedLayers = new Array;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
var c = desc.count
var selectedLayers = new Array();
for(var i=0;i<c;i++){
try{
activeDocument.backgroundLayer;
selectedLayers.push( desc.getReference( i ).getIndex() );
}catch(e){
selectedLayers.push( desc.getReference( i ).getIndex()+1 );
}
}
}else{
var ref = new ActionReference();
ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
try{
activeDocument.backgroundLayer;
selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1);
}catch(e){
selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" )));
}
var vis = app.activeDocument.activeLayer.visible;
if(vis == true) app.activeDocument.activeLayer.visible = false;
var desc9 = new ActionDescriptor();
var list9 = new ActionList();
var ref9 = new ActionReference();
ref9.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
list9.putReference( ref9 );
desc9.putList( charIDToTypeID('null'), list9 );
executeAction( charIDToTypeID('Shw '), desc9, DialogModes.NO );
if(app.activeDocument.activeLayer.visible == false) selectedLayers.shift();
app.activeDocument.activeLayer.visible = vis;
}
return selectedLayers;
};
Copy link to clipboard
Copied
I'm sorry for longest timeout 🙂
After I'm started this script in the row "var ref = new ActionReference();" is error - ActionReference has no a cinstructor. What I can do ?
Copy link to clipboard
Copied
Where are you running the script from? If you are using ESKT make sure Photoshop is the target app or add #target photoshop at the top of the script.
As far as I know only Photoshop has an ActionReference class. If another app is running the script you will get that error. The default target app for ESTK is ESTK itself.
Copy link to clipboard
Copied
Yes ! Thanks !