Получить элементы пользовательского интерфейса приложения, открытого Finder, с помощью AppleScript - PullRequest
0 голосов
/ 20 июня 2020
set classNames to {}
tell application "Finder"
    tell front window of (first application process whose frontmost is true)
        set uiElems to entire contents as list
    end tell
end tell

Когда я запускаю это в редакторе скриптов, он возвращает:

{group 1 of window "test" of application process "Script Editor" of application "Finder", pop up button 1 of group 1 of window "test" of application process "Script Editor" of application "Finder", pop up button 2 of group 1 of window "test" of application process "Script Editor" of application "Finder", checkbox 1 of window "test" of application process "Script Editor" of application "Finder", checkbox 2 of window "test" of application process "Script Editor" of application "Finder", checkbox 3 of window "test" of application process "Script Editor" of application "Finder", busy indicator 1 of window "test" of application process "Script Editor" of application "Finder", static text "Running…" of window "test" of application process "Script Editor" of application "Finder", splitter group 1 of window "test" of application process "Script Editor" of application "Finder", splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", scroll area 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", text area 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", scroll bar 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", splitter 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", group 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", static text "Result" of group 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", scroll area 1 of group 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", text area 1 of scroll area 1 of group 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", scroll bar 1 of scroll area 1 of group 1 of splitter group 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", splitter 1 of splitter group 1 of window "test" of application process "Script Editor" of application "Finder", toolbar 1 of window "test" of application process "Script Editor" of application "Finder", button 1 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", button 2 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", button 3 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", button 4 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", group 1 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", group 1 of group 1 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", checkbox 1 of group 1 of group 1 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", checkbox 2 of group 1 of group 1 of toolbar 1 of window "test" of application process "Script Editor" of application "Finder", static text "—" of window "test" of application process "Script Editor" of application "Finder", button 1 of window "test" of application process "Script Editor" of application "Finder", button 2 of window "test" of application process "Script Editor" of application "Finder", button 3 of window "test" of application process "Script Editor" of application "Finder", menu button "Edited" of window "test" of application process "Script Editor" of application "Finder", image "test" of window "test" of application process "Script Editor" of application "Finder", static text "test" of window "test" of application process "Script Editor" of application "Finder"}

Но когда я пытаюсь запустить скрипт как приложение и пытаюсь открыть приложение через Finder, возникает ошибка:

Can’t get window 1 of application process 1 whose frontmost = true. Invalid index. (-1719)

Может кто с этим поможет? Я новичок в AppleScript и понятия не имею.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...