【发布时间】:2012-10-12 20:59:38
【问题描述】:
我的一个 AppleScript 遇到了问题。 我正在尝试创建一个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
说完
我想要改进的是一种在选中或取消选中之前先验证该框是否选中或取消选中的方法。
感谢您的帮助。
【问题讨论】:
标签: macos checkbox applescript osx-mountain-lion