我对AppleScript的整体表现非常不错,所以我觉得这对我来说并不难以在正确的方向上稍微推动一下。我浏览过网站,发现其他一些不使用AppleScript的方法,但由于AppleScript主要是我所知道的,我更愿意将其用于此目的。
所以,无论如何,我想要做的是在进行我想做的事情之前查看进程是否已经运行(激活)。这应该有助于澄清我想要做的事情:
tell application "AppleWorks 6" to activate
tell application "System Events"
repeat until "AppleWorks 6" is in the processes
delay 3
end repeat
end tell
--do script stuff with AppleWorks
当我尝试这个时,它返回false,即使AppleWorks正在运行:
"AppleWorks 6" is in the processes
非常感谢任何基本帮助
答案 0 :(得分:1)
如果您运行的是比Leopard更晚的OS X版本,则可以使用running
属性,因此不需要系统事件。
tell application "AppleWorks 6" to activate
repeat
delay 0.2
if (running of application "AppleWorks 6") then exit repeat
end repeat
答案 1 :(得分:0)
您想要检查每个进程的“name”属性。试试这个......
tell application "AppleWorks 6" to activate
tell application "System Events"
repeat until "AppleWorks 6" is in name of processes
delay 3
end repeat
end tell
--do script stuff with AppleWorks