閱讀問題「Programmatically select text range in TextEdit」後,我很好奇爲什麼AXSelectedTextRange屬性無法在AppleScript中設置,即使屬性指示它可設置。無法在AppleScript中設置可設置的輔助功能屬性
打開一個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如何處理我誤解的可訪問性屬性有什麼不同嗎?
真的很棒的答案! – kopischke
很好的解釋傑克,謝謝! – adayzdone