我正面临着我的一个问题。 我正在尝试创建一个AppleScript,在mac唤醒或屏幕保护程序在mac安全面板中停止后,选中/取消选中调用密码的复选框。 我正在使用proximity.app,并认为当我回到家并且我的手机在范围内时,proximity.app会删除密码,但是当我超出范围时,它会将密码放回原处。 嗯......由于Mountain Lion中新的安全策略,我不得不使用UI脚本来完成它。
因此超出范围时会出现代码:
tell application "System Preferences"
set current pane to pane id "com.apple.preference.security"
tell application "System Events"
tell process "System Preferences"
tell first window
tell first tab group
click radio button 1
if not 1 then click checkbox 1
click menu item 6 of menu of pop up button 1
end tell
end tell
end tell
end tell
quit
告诉
在范围内时:
tell application "System Preferences"
set current pane to pane id "com.apple.preference.security"
tell application "System Events"
tell process "System Preferences"
tell first window
tell first tab group
click radio button 1
click checkbox 1
end tell
end tell
end tell
end tell
quit
告诉
我想要改进的方法是首先验证是否在检查或取消选中该复选框之前验证该框。
感谢您的帮助。
答案 0 :(得分:4)
只需检查checkbox
。
0 =取消选中, 1 =检查
tell application "System Preferences" to ¬
reveal anchor "Advanced" of pane id "com.apple.preference.security"
tell application "System Events"
tell first tab group of first window of process "System Preferences"
tell checkbox 1 to if value is 0 then click -- checkbox was not checked.
end tell
end tell
quit application "System Preferences"