下面是一个使用AppleScript选择滚动区域中所有复选框的示例代码:
tell application "System Events"
tell process "YourAppName" -- 替换为你要操作的应用的名称
set checkboxList to {}
-- 获取滚动区域的窗口或UI元素
set scrollArea to first window whose subrole is "AXScrollArea"
-- 获取滚动区域中的所有复选框
set checkboxes to every checkbox of scrollArea
-- 遍历复选框并选择它们
repeat with checkbox in checkboxes
set checkboxName to name of checkbox
set checkboxState to value of checkbox as boolean
-- 如果复选框未选中,则选择它
if not checkboxState then
set value of checkbox to 1
set end of checkboxList to checkboxName
end if
end repeat
end tell
end tell
-- 输出选择的复选框的名称
if checkboxList is not equal to {} then
set AppleScript's text item delimiters to ", "
display alert "选择的复选框:" & (checkboxList as text)
else
display alert "没有找到复选框。"
end if
请注意,你需要将YourAppName
替换为你要操作的应用的名称。此脚本遍历滚动区域中的所有复选框,并选择未选中的复选框。最后,它将显示一个警告框,显示选择的复选框的名称。