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