Check if layer is selected
Hello guys i'm currently facing a problem here, i want to check if photoshop is currently selected a group , if yes run the function, if not alert the feedback but i don't know why it not working this is the code i wrote
#target photoshop
// Function to check if a layer is selected
function isLayerSelected() {
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
return executeActionGet(ref).hasKey(stringIDToTypeID("targetLayers"));
}
// Main function
function main() {
if (isLayerSelected()) {
// Call your function here if a layer is selected
loadFunction();
} else {
// Display a warning if no layer is selected
alert("No layer is currently selected.");
}
}
// Function to be called when a layer is selected
function loadFunction() {
app.doAction("Test", "CGIBA");
}
app.activeDocument.suspendHistory("Test", "func2()");

