Return 布尔值是否通过系统事件在 AppleScript 中进程是否 运行
Return a boolean value whether or not a process is running in AppleScript through System Events
总的来说,我对 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
任何基本帮助将不胜感激
您想检查每个进程的"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
如果您 运行 是比 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
总的来说,我对 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
任何基本帮助将不胜感激
您想检查每个进程的"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
如果您 运行 是比 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