forked from moluapple/ExtendScripts4AI-ID
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAI_timeToSave.jsx
79 lines (72 loc) · 2.14 KB
/
AI_timeToSave.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/***************************
* 作为bridge启动脚本使用
* 每15分钟弹出图片提示保存文件
* 点击图片使弹窗关闭
* 测试环境: AI CS5 Win7
* ImageURL: http://cdn1.iconfinder.com/data/icons/pry_hardware/512/Time_Machine.png
***************************/
#target bridge
var time = 15; //时间设定,分钟
function saveMe (){
/*#targetengine 'session';*/
if (app.documents.length){
var w, img;
w = new Window ('palette', undefined, undefined, {borderless: true});
img = w.add ('image', undefined, File('~/desktop/Time.png'));
w.margins = [0,0,0,0];
img.addEventListener('click', function (){w.close(0); w = null});
w.show();
}
}
function autoSave(){
BridgeTalk.bringToFront('illustrator');
var btMsg = new BridgeTalk();
btMsg.target = 'illustrator';
btMsg.body = saveMe.toSource() + '();';
btMsg.send();
}
function AIAutoSavePopup()
{
this.requiredContext = "\tAdobe Bridge must be running.\n\tExecute against Bridge CS5 as the target.\n";
this.menuID = "tools/ai";
this.menuCommandID = "tools/ai/启用自动保存提示";
this.processId = 0;
$.level = 1;
}
AIAutoSavePopup.prototype.run = function(){
var retval = true;
if(!this.canRun()) {
retval = false;
return retval;
}
var popupCommand = MenuElement.create( "command", "启用自动保存提示", "at the end of " + this.menuID, this.menuCommandID );
popupCommand.onSelect = function (m){
if (m.text == '启用自动保存提示'){
app.scheduleTask('autoSave()', time * 60000, true);
AIAutoSavePopup.processId = d;
m.text = '停用自动保存提示';
} else {
try {
app.cancelTask(AIAutoSavePopup.processId);
} catch(e) {
alert(e);
}
m.text = '启用自动保存提示';
}
}
return retval;
}
AIAutoSavePopup.prototype.canRun = function(){
if(BridgeTalk.appName == "bridge") {
if((MenuElement.find(this.menuID)) && (MenuElement.find(this.menuCommandID)))
{
$.writeln("Error:Menu element already exists!\nRestart Bridge to run this snippet again.");
return false;
}
return true;
}
$.writeln("ERROR:: Cannot run AIAutoSavePopup");
$.writeln(this.requiredContext);
return false;
}
new AIAutoSavePopup().run();