AppleScript无法单击“系统偏好设置”复选框,尽管它没有显示错误

问题描述 投票:0回答:1

错误

我已经在下面编写了代码,在选择该行之前,它似乎一直有效。

但是,即使没有出现任何错误,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

参考

我搜索了很多文章,但没有解决。

How to click a checkbox of a drop-down tab in System Preferences

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

感谢您的任何帮助。

macos applescript macos-mojave
1个回答
0
投票

也许尝试一下:

click checkbox of UI element 1 of current_row
© www.soinside.com 2019 - 2024. All rights reserved.