var myDoc = app.activeDocument;
function RMLayerBG() {
var feather = 0;
var antiAlias = true;
for (var i = 1; i < myDoc.artLayers.length + 1; i++) {
SelectAndRemoveBGArea(i);
}
}
function SelectAndRemoveBGArea(layerNum) {
var dTimeline = new ActionDescriptor();
var rTimeline = new ActionReference();
rTimeline.putIndex(stringIDToTypeID("animationFrameClass"), layerNum);
dTimeline.putReference(stringIDToTypeID("null"), rTimeline);
executeAction(stringIDToTypeID("select"), dTimeline, DialogModes.NO);
var dLayer = new ActionDescriptor();
var rLayer = new ActionReference();
rLayer.putName(stringIDToTypeID("layer"), "图层 " + layerNum);
dLayer.putReference(stringIDToTypeID("null"), rLayer);
dLayer.putBoolean(stringIDToTypeID("makeVisible"), false);
var list = new ActionList();
list.putInteger(4);
dLayer.putList(stringIDToTypeID("layerID"), list);
executeAction(stringIDToTypeID("select"), dLayer, DialogModes.NO);
var dSelect = new ActionDescriptor();
dSelect.putBoolean(stringIDToTypeID("sampleAllLayers"), false);
executeAction(stringIDToTypeID("autoCutout"), dSelect, DialogModes.NO);
myDoc.selection.invert();
myDoc.selection.clear();
myDoc.selection.deselect();
}
function WandSelect() {
var d = new ActionDescriptor();
var r = new ActionReference();
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
d.putReference(stringIDToTypeID("null"), r);
var d1 = new ActionDescriptor();
d1.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), 20);
d1.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), 20);
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("point"), d1);
d.putInteger(stringIDToTypeID("tolerance"), 5);
d.putBoolean(stringIDToTypeID("antiAlias"), true);
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
}
RMLayerBG();