检查应用程序是否在 AppleScript 中运行的更快方法

saa*_*jha 1 applescript

我正在一个应该响应的程序中使用AppleScript,但似乎我在检查应用程序是否正在运行时遇到了瓶颈,这需要大约半秒\xe2\x80\xa6有没有办法减少这?

\n\n

这是我目前正在做的事情:

\n\n
if application "Finder" is running then\n    tell application "Finder" to activate\nend if\n
Run Code Online (Sandbox Code Playgroud)\n

pbe*_*ell 5

这就是我正在使用的(在本例中为 Word),它看起来足够快(不到 0.5 秒)。结果是 Appli_Launch = true 或 false :

tell application "System Events" to set Appli_Launch to exists (processes where name is "Microsoft Word")
Run Code Online (Sandbox Code Playgroud)