AppleScript:如何在“系统偏好设置”中识别复选框位置?

时间:2016-01-04 13:19:53

标签: macos applescript

我想发出一个键盘命令来切换OS X Desktop 1(我的主显示器桌面)中的“每30分钟更改一次图片”复选框。我有多个监视器,因此可能需要确定要操作的特定首选项窗格。

我已经设置了AppleScript的开头,但我不知道如何制定如何识别这个特定的复选框:

tell application "System Preferences"
    activate
end tell

tell application "System Events"
    tell process "System Preferences"
        click menu item "Desktop & Screen Saver" of menu "View" of menu bar 1
    delay 2
    tell window "Desktop & Screen Saver"
        click checkbox 1 of …

enter image description here

1 个答案:

答案 0 :(得分:1)

它在tab group 1。您可以借助Xcode工具辅助功能检查器(Xcode> Open Developer Tool>菜单栏或Dock中的辅助功能检查器)来识别这一点。

tell application "System Preferences"
    activate
    set the current pane to pane id "com.apple.preference.desktopscreeneffect"
end tell

delay 2

tell application "System Events" to tell process "System Preferences"
    click checkbox "Change picture:" of tab group 1 of window "Desktop & Screen Saver"
end tell