0
窗口正常打開,但腳本將而不是繼續,直到彈出窗口手動關閉!這是不可取的,因爲我寧願窗口關閉本身 秒後...
所以我必須從腳本的其餘部分一個單獨的線程,打開窗口?這甚至有可能嗎?
這裏是我到目前爲止的代碼:
InDesign CS5腳本:如何在'n`秒後打開和關閉彈出窗口?
function showMessageWindow()
{
var script = getScriptName(); // initialized from the function below
var message = new Window("dialog", script);
message.add("StaticText", undefined, "The script " + script + " is now running, please wait...");
message.show();
var startTime = new Date().getTime(); // in milliseconds
var currentTime = new Date().getTime(); // in milliseconds
var waitTime = 5000; // 1000 milliseconds is 1 second
var delay = function()
{
while((currentTime - startTime) < waitTime)
{
currentTime = new Date().getTime(); // in milliseconds
}
} // end of closure delay
delay(); // calling the delay closure function here
message.close(); // close the message after the specified delay time
} // end of function showMessageWindow
// called from the function showMessageWindow
function getScriptName()
{
var scriptName = "";
try
{
scriptName = File(app.activeScript).name;
}
catch(e)
{
scriptName = File(e.fileName).name;
}
return scriptName;
} // end of function getScriptName
感謝@Loic!嗯,動作腳本...這也可以用VBA或AppleScript,或者是ActionScript特別有用嗎?這很有趣,儘管我選擇使用確認框,如果單擊「否」(*不是*異步,但用戶友好以用於我的目的),則調用'exit()'。啊,'*小寫* statictext',謝謝指出。 – 2012-07-18 05:17:38
不知道Applescript既不能幫助。我不知道VB提供什麼。 – Loic 2012-07-18 22:13:12
applescript,vb和javascript具有相同的功能 – 2014-11-14 14:39:47