use*_*912 3 macos checkbox applescript osx-mountain-lion
我的一个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
Run Code Online (Sandbox Code Playgroud)
结束告诉
并且在范围内时:
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
Run Code Online (Sandbox Code Playgroud)
结束告诉
我要改进的是一种在选中或取消选中该框之前先验证该框是选中还是未选中的方法。
谢谢你的帮助。
只需检查的值即可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"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3183 次 |
| 最近记录: |