function 历史记录保留() { app.activeDocument.suspendHistory("历史记录保留", "历史记录保留()"); } function 历史记录保留() { 主文档 = app.activeDocument; 主文档名称 = 主文档.name; // 遍历当前打开的文档 for (var i = 0; i < app.documents.length; i++) { var document = app.documents[i]; var documentName = document.name; // 判断文档名称是否与主文档名称不相同 if (documentName !== 主文档名称) { // 设置当前文档为活动文档 app.activeDocument = document; 取消选择() 历史记录快照保留() } } app.activeDocument = 主文档 } function 历史记录快照保留() //删除图层 { var d = new ActionDescriptor(); var r = new ActionReference(); r.putClass(stringIDToTypeID("snapshotClass")); d.putReference(stringIDToTypeID("null"), r); var r1 = new ActionReference(); r1.putProperty(stringIDToTypeID("historyState"), stringIDToTypeID("currentHistoryState")); d.putReference(stringIDToTypeID("from"), r1); executeAction(stringIDToTypeID("make"), d, DialogModes.NO); } function 取消选择() //取消选择 { var d = new ActionDescriptor(); var r = new ActionReference(); r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection")); d.putReference(stringIDToTypeID("null"), r); d.putEnumerated(stringIDToTypeID("to"), stringIDToTypeID("ordinal"), stringIDToTypeID("none")); executeAction(stringIDToTypeID("set"), d, DialogModes.NO); }