阅读问题“<a href="https://stackoverflow.com/questions/10487350/programmatically-select-text-range-in-textedit" title="Programmatically select text range in TextEdit">Programmatically select text range in TextEdit”,我很好奇为什么不能在 AppleScript 中设置AXSelectedTextRange属性,即使属性表明它是可设置的。
打开一个 TextEdit 文档,键入几行,突出显示一部分并运行下面的脚本进行测试。
activate application "TextEdit"
tell application "System Events"
set attr to attribute "AXSelectedTextRange" of text area 1 of scroll area 1 of window "Untitled" of application process "TextEdit"
attr's properties -- determine if settable
set attr's value to {1, 2}
delay 1
attr's value
end tell
AppleScript 如何处理我缺少的可访问性属性有什么不同吗?