无法通过 AppleScript 单击系统偏好设置的复选框,尽管它没有显示错误
Unable to click checkbox of System Preferences by AppleScript, although it doesn't show errors
错误
我写了下面的代码,它似乎一直有效,直到 select 行。
然而,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
感谢任何帮助。
变化:
click checkbox of current_row
收件人:
click checkbox of UI element 1 of current_row
在 macOS Mojave 上测试了您的脚本,进行了如上所示的更改,并按预期运行。
错误
我写了下面的代码,它似乎一直有效,直到 select 行。
然而,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
感谢任何帮助。
变化:
click checkbox of current_row
收件人:
click checkbox of UI element 1 of current_row
在 macOS Mojave 上测试了您的脚本,进行了如上所示的更改,并按预期运行。