我的脚本分析了一堆InDesign文件。关于丢失字体等的任何警告都是无关紧要的,因此我在核心工作期间关闭了用户交互:
// preparation code
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
// core work code
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
// finish code
尽管如此,我想展示一个进度条。我用ScriptUI设置了这个:
progressPanel = new ProgressPanel(files.length, 500);
progressPanel.show();
for (i = 0; i < files.length; i++) {
processFile( files[i] );
progressPanel.incr();
progressPanel.setText( files[i].name );
progressPanel.show();
}
// Progress Panel, inspired from:
// http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/indesign/sdk/cs6/scripting/InDesign_ScriptingGuide_JS.pdf
// We make it a class.
function ProgressPanel (myMaximumValue, myProgressBarWidth){
this.myProgressPanel = new Window('window', 'analyse InDesign files…');
this.value = 0;
this.myProgressPanel.myProgressBar
= this.myProgressPanel.add('progressbar',
[12, 12, myProgressBarWidth, 24],
0, myMaximumValue);
this.myProgressPanel.myText
= this.myProgressPanel.add("statictext",
[15, 6, myProgressBarWidth, 24]);
this.show = function() {
this.myProgressPanel.show();
}
this.hide = function() {
this.myProgressPanel.hide();
}
this.setValue = function(value) {
this.value = value;
this.myProgressPanel.myProgressBar.value = value;
}
this.incr = function() {
var inc = arguments.length ? arguments[0] : 1;
this.value += inc;
this.myProgressPanel.myProgressBar.value = this.value;
}
this.setText = function(text) {
this.myProgressPanel.myText.text = text;
}
}
这在InDesign CS 6中运行良好。但在CC 2015中没有,除非我删除所有NEVER_INTERACT语句。
在InDesign CS 6及更高版本中,如何在抑制其他用户交互的同时显示我的进度条?
答案 0 :(得分:0)
至少对于InDesign CC 2017,调用 win.update()就可以了! (有关ID CC中调色板窗口的更多信息,请参阅Adobe论坛中的Progress Bar bug. Summary of the situation。)
this.show = function() {
this.win.show();
this.win.update();
}
this.incr = function() {
var inc = arguments.length ? arguments[0] : 1;
this.value += inc;
this.myProgressBar.value = this.value;
this.win.update();
}