That is certainly strange! It seems that there should be a guid for every object in Photoshop. I can certainly make each layer name unique but I was hoping for a more direct access approach.
Thanks for all your help
Action Manager does not have direct access to objects in the Object Model. It has it's own classes and object. Sometimes there can be a more direct access than by name. If the event descriptor had the layer index or ID you could use that instead of the name.
Sorry, when I threw this together for you I only tested hidding layers that were not the activeLayer. I don't think the reason the alert is empty is because the top layer was hidden. I think it's because the activeLayer was hidden so the actionReference is different.
Try this( seems to work for me with both )
try {
if (arguments.length >= 2) {
var desc = arguments[0];
var event = arguments[1];
// make sure it's the hide event
if (event == charIDToTypeID('Hd ')) {
// get the list of what was hidden
var list = desc.getList(charIDToTypeID('null'));
// get the actionReferences from the list
var ref = list.getReference(0);
var psClass = ref.getDesiredClass();
// make sure it was a layer that was hidded
if(psClass == charIDToTypeID('Lyr ')){
// check to see what is in the reference
var dataEnum = ref.getForm();
// should either be an enum if activeLayer
if(dataEnum == ReferenceFormType.ENUMERATED) {
alert(app.activeDocument.activeLayer.name);
}else{// or the layer name
alert(ref.getName());
}
}
}
}
} catch (e) {
alert( "Error: " + e + ":" + e.line );
}