admin管理员组文章数量:1377698
This should be relatively simple. While writing a script for Adobe InDesign CS6, I'd like to have a window/palette appear briefly—say, about two seconds— to notify the user that the end of the script was reached successfully. How can I go about doing this?
This should be relatively simple. While writing a script for Adobe InDesign CS6, I'd like to have a window/palette appear briefly—say, about two seconds— to notify the user that the end of the script was reached successfully. How can I go about doing this?
Share Improve this question edited Jan 19, 2020 at 14:45 RobC 25.1k21 gold badges84 silver badges86 bronze badges asked Jun 18, 2013 at 17:35 SturmSturm 7792 gold badges28 silver badges57 bronze badges2 Answers
Reset to default 4try this:
main();
function main(){
var progress_win = new Window ("palette");
var progress = progress_bar(progress_win, 2, 'Doing Something. Please be patient');
delay(1);
progress.value = progress.value+1;
delay(1);
progress.parent.close();
}
// delay function found here
//found here http://www.wer-weiss-was.de/theme157/article1143593.html
function delay(prmSec){
prmSec *= 1000;
var eDate = null;
var eMsec = 0;
var sDate = new Date();
var sMsec = sDate.getTime();
do {
eDate = new Date();
eMsec = eDate.getTime();
} while ((eMsec-sMsec)<prmSec);
}
/**
* Taken from ScriptUI by Peter Kahrel
*
* @param {Palette} w the palette the progress is shown on
* @param {[type]} stop [description]
* @return {[type]} [description]
*/
function progress_bar (w, stop, labeltext) {
var txt = w.add('statictext',undefined,labeltext);
var pbar = w.add ("progressbar", undefined, 1, stop);
pbar.preferredSize = [300,20];
w.show ();
return pbar;
}
Your answer provided me with an idea for my script: instead of just having a pop-up that says "I'm done!", show a progress bar! So, using the ScriptUI for dummies document, I was able to e up with the following code for the beginning of the script:
// Creating a progress bar window.
var w = new Window("palette");
var progress = progress_bar(w, 27);
var currentDoc = w.add("statictext");
currentDoc.text = "Processing " + document.name;
w.show();
Then, throughout the script, peppering it with progress.value += 1;
statements (usually whenever a single process has been pleted), which totaled 27. At the end of the main function, I dropped a simple progress.parent.close();
line. Finally, after the main function, I dropped in the progress_bar()
function:
/**
* Creates the actual progress bar object
*
* @param {Palette} w The pallette the progress is shown on
* @param {number} stop The value which represents 100% of the progress bar
*/
function progress_bar(w, stop) {
var pbar = w.add("progressbar", undefined, 1, stop);
pbar.preferredSize = [300, 20];
return pbar;
}
And that seems to do it! The progress bar appears, crawls to the end while it processes the file, then once the progress bar closes, the script is done! Thanks for pointing me in a much better direction, fabiantheblind!
本文标签: JavascriptExtendScriptScriptUI temporary window messageStack Overflow
版权声明:本文标题:JavascriptExtendScriptScriptUI temporary window message - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744478940a2608045.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论