Macos 在使用Applescript单击之前验证复选框
我的一个applescript出现了问题。 我正在尝试创建一个applescript,在mac唤醒或mac security pannel中的屏幕保护程序停止后,选中/取消选中调用密码的复选框。 我将它与approxity.app一起使用,我的想法是,当我回到家,手机在范围内时,approxity.app会删除密码,但当我在范围外时,它会将密码放回。 好。。。由于Mountain Lion的新安全策略,我不得不使用UI脚本来完成这项工作 因此,超出范围时会出现代码:Macos 在使用Applescript单击之前验证复选框,macos,checkbox,applescript,osx-mountain-lion,Macos,Checkbox,Applescript,Osx Mountain Lion,我的一个applescript出现了问题。 我正在尝试创建一个applescript,在mac唤醒或mac security pannel中的屏幕保护程序停止后,选中/取消选中调用密码的复选框。 我将它与approxity.app一起使用,我的想法是,当我回到家,手机在范围内时,approxity.app会删除密码,但当我在范围外时,它会将密码放回。 好。。。由于Mountain Lion的新安全策略,我不得不使用UI脚本来完成这项工作 因此,超出范围时会出现代码: tell applicati
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=取消选中,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"
是的,很有效,谢谢!仅采用这种方式:code
tell-application“系统首选项”将当前窗格设置为窗格id“com.apple.preference.security”tell-application“系统事件”tell-process“系统首选项”告诉第一个窗口告诉第一个选项卡组单击单选按钮1告诉复选框1如果值为0,则单击--复选框未选中。单击弹出按钮1菜单的菜单项6 end tell end tell end tell end tell退出end tellcode