我正在尝试使用以下脚本在系统偏好设置中导航至安全性窗格,如果窗格已打开并已最小化,则脚本无法将其显示在前面。激活有办法吗,我可以把它放在前面
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.security"
end tell
答案 0 :(得分:1)
此脚本检查窗口的状态。
如果该窗口可见,则什么也不做。
tell application "System Preferences"
activate
if exists window "Security & Privacy" then
tell window "Security & Privacy" to if it is miniaturized then set miniaturized to false
else
set current pane to pane "com.apple.preference.security"
end if
end tell
答案 1 :(得分:0)
我只需退出系统偏好设置,然后再次将其激活:
tell application "System Preferences"
quit
activate
set current pane to pane "com.apple.preference.security"
end tell
注意:有时,由于两个进程重叠,因此退出然后立即激活应用程序可能会失败,从而产生错误。如果发生这种情况,下面的其他几行(在原始答案的上下文中添加)将缓解这种情况:
tell application "System Preferences"
quit
repeat while it is running
delay 0.2
end repeat
activate
set current pane to pane "com.apple.preference.security"
end tell