Невозможно установить флажок «Системные настройки» AppleScript, хотя он не отображает ошибки - PullRequest
0 голосов
/ 07 марта 2020

Ошибки

Я написал код ниже, и, кажется, он работает, пока не выберет строку.

Однако click checkbox не работает, хотя и не дает любые ошибки.

tell application "System Preferences"
    activate
    reveal anchor "shortcutsTab" of pane id "com.apple.preference.keyboard"
end tell
tell application "System Events"
    tell application process "System Preferences"
        repeat while not (window 1 exists)
        end repeat
    tell window 1

    repeat while not (rows of table 1 of scroll area 1 of splitter group 1 of tab group 1 exists)
    end repeat

    repeat with current_row in (rows of table 1 of scroll area 1 of splitter group 1 of tab group 1)
        if value of static text 1 of current_row is equal to "Input Sources" then
            select current_row
            exit repeat
        end if
    end repeat

    repeat while not (rows of outline 1 of scroll area 2 of splitter group 1 of tab group 1 exists)
    end repeat

    repeat with current_row in rows of outline 1 of scroll area 2 of splitter group 1 of tab group 1
        if name of UI element 2 of current_row is equal to "Select next source in input menu" then
            select current_row
            click checkbox of current_row
            exit repeat
        end if
    end repeat

    end tell
    end tell
end tell

То, что я пробовал

Я альтернативно написал ниже, но все они не работают.

set value of checkbox of selected_row
set checkbox of selected_row to true

Ссылки

I обыскал много статей, но это не помогло.

Как установить флажок раскрывающейся вкладки в Системных настройках

http://hints.macworld.com/article.php?story=20040317131326880

Любая помощь приветствуется.

1 Ответ

1 голос
/ 07 марта 2020

Изменение:

click checkbox of current_row

На:

click checkbox of UI element 1 of current_row

Протестировал ваш скрипт на MacOS Mojave, внеся изменения, показанные выше, и все заработало как надо.

...