例:Safariなどでホームページの階層を利用した場合はこんな感じです。
tell application "System Events" to set value of text field 1 of group 2 of UI element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window 1 of application process "Safari" to "アップルスクリプト"
●メモ「インターネットブラウザSafariでUIスクリプト参照式を取得するコツ」2019年10月1日
スクリプト参照式で途中まで階層を探って、例えばSafariで閲覧したホームページでは、
Safariの階層がUI element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window 1 of application process "Safari"
で、この先がホームページの階層になります。なので、これの先頭に「 every UI element」か「 UI elements of 」とコピーしておき、後ろに検索条件の「whose name is "検索文字"」(text fieldの内容の場合はvalue is "検索文字")を追加して、先頭にペーストして追加しながらスクリプトエディタで繰り返し実行していくと、
結果に式が返されます。ちなみにこのページの検索条件というtext fieldとstatic textは、
tell application "System Events"
UI elements of UI elements of UI elements of UI elements of UI elements of UI elements of UI element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window 1 of application process "Safari" whose name is "検索文字"
end tell
で結果が得られ、このようになります。
{{{{{}, {{}}, {{}}, {{}}, {{}}, {{}}, {{}}, {{}}, {{}}, {{}}, {{}}, {{}}, {{}}, {{}}, {{}}}}, {}, {}}, {{{{{static text "検索文字" of group 1 of UI element 1 of scroll area 1 of UI element 1 of scroll area 2 of UI element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window "AppleScriptクラブ" of application process "Safari" of application "System Events", text field 1 of group 1 of UI element 1 of scroll area 1 of UI element 1 of scroll area 2 of UI element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window "AppleScriptクラブ" of application process "Safari" of application "System Events"}, {}, {}, {}}, {}}, {{{}}}}}}