Как получить уведомление субтитров / тела с помощью AppleScript? - PullRequest
1 голос
/ 01 апреля 2020

Я пытаюсь прочитать заголовок и подзаголовок уведомлений macOS, используя AppleScript. Мне удалось получить заголовок, используя приведенный пример здесь (номер 5), но мне также нужно получить субтитры.

Вот код, который возвращает заголовок:

on run
    tell application "System Events"
        tell process "Notification Center"
            set theseWindows to every window
            set theseTitles to {}
            repeat with thisWindow in theseWindows
                try
                    set thisTitle to the value of static text 1 of thisWindow
                    set the end of theseTitles to thisTitle
                end try
            end repeat
            return theseTitles
        end tell
    end tell
end run

Кто-нибудь знает, как я могу получить субтитры для уведомлений?

1 Ответ

1 голос
/ 01 апреля 2020

Запуск следующего примера AppleScript кода в Редактор сценариев :

display notification "Body Text Line" with title "Title Text Line" subtitle "Subtitle Text Line"

Создает это уведомление:

enter image description here

Затем выполняется следующий пример AppleScript код в Редактор сценариев :

tell application "System Events"
    tell application process "NotificationCenter"
        get value of static text 1 of window 1
        get value of static text 1 of scroll area 1 of window 1
        get value of static text 2 of scroll area 1 of window 1
    end tell
end tell

Показывает следующий вывод в панели Ответы Редактор сценариев :

tell application "System Events"
    get value of static text 1 of window 1 of application process "NotificationCenter"
        --> "Title Text Line"
    get value of static text 1 of scroll area 1 of window 1 of application process "NotificationCenter"
        --> "Subtitle Text Line"
    get value of static text 2 of scroll area 1 of window 1 of application process "NotificationCenter"
        --> "Body Text Line"
end tell


Как видите, это get value of static text 1 of scroll area 1 of window 1, который возвращает субтитры .

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