Created
April 17, 2012 09:20
-
-
Save moluapple/2404831 to your computer and use it in GitHub Desktop.
[Indesign]EventListener AutosaveACopy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#targetengine "autosaveACopy" | |
(function () { | |
var f = new Folder("/E/autosave"), | |
doc = app.documents.item(0); | |
!f.exists && f.create(); | |
doc.isValid && doc.addEventListener("beforeSave", backUp); | |
function backUp(docEvent) { | |
var doc = docEvent.parent, | |
ver = Number(doc.extractLabel('version')); | |
doc.insertLabel('version', ++ver + ''); | |
app.idleTasks.add({sleep: 100}).addEventListener(IdleEvent.ON_IDLE, saveCopy); | |
function saveCopy(ev) { | |
var fn = f + '/' + doc.name.replace(/\.indd$/, '') + '_存档_' + ver + ".indd"; | |
doc.saveACopy(File(fn)); | |
ev.target.sleep = 0; | |
} | |
} | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#targetengine "disableSave" | |
app.activeDocument.addEventListener('beforeSave', function(ev) { | |
alert('不准直接保存'); | |
ev.stopPropagation(); | |
ev.preventDefault(); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment