нажмите кнопку на всплывающем окне - PullRequest
0 голосов
/ 04 марта 2020

Я работаю над проектом автоматизации appleScript. Я не могу найти способ нажать на кнопку в всплывающем окне. (Моя система - MacOS Sierra 10.12.6). См. Изображение:

скриншот инспектора доступности кнопки

Родитель кнопки -

<empty desctiption> (popover) [_NSPopoverWindow]

Теперь я не нашел способа ссылаться на эту кнопку. Вот что я попробовал:

tell application "System Events"
    tell process "NordVPN"
        click menu bar item 1 of menu bar 2  --open the popover window to access the button on the window

        delay 0.5

        --get the entire contents of menu bar 2
        --click (button whose title is "Preferences")
        --click button 1 of menu 1 of menu bar item 1 of menu bar 2
        --click button 1 of NSPopover of menu bar item 1 of menu bar 2
        --click button 1 of NSPopover of menu bar 2
        --click button 1 of popover of menu bar item 1 of menu bar 2
        click button 1 of _NSPopoverWindow of menu bar item 1 of menu bar 2
        --click button 1 of window 1 of menu bar item 1 of menu bar 2
        --click button 1
    end tell
end tell

Все они провалились. И не могу найти полезную информацию о Google и переполнении стека.

1 Ответ

0 голосов
/ 04 марта 2020

Проблема сценариев GUI всегда заключается в определении иерархии элементов GUI, чтобы вы могли правильно ссылаться на нужный элемент. На скриншоте, который вы дали, я бы попробовал следующее в качестве первой попытки:

tell application "System Events"
    tell process "NordVPN"
        tell second menu bar
            tell first button
                click --open the popover window to access the button on the window

                delay 0.5
                tell first pop over
                    tell button "Preferences"
                        click
                    end tell
                end tell
            end tell
        end tell
    end tell
end tell

Если это не сработает, вам придется продвигаться вверх по иерархии, используя ссылку UI Elements или entire contents свойство каждого данного элемента. Например, вы можете сказать:

tell application "System Events"
    tell process "NordVPN"
        tell second menu bar
            tell first button
                click --open the popover window to access the button on the window

                delay 0.5
                tell first pop over
                    -- to get a list of all the contents of the the popover 
                    entire contents

                    -- to get the immediate (first level) contents of the popover
                    UI elements
                end tell
            end tell
        end tell
    end tell
end tell

, любой из которых даст в журнале редактора сценариев список элементов всплывающего окна. Затем вы можете поэкспериментировать с элементами, чтобы найти путь к нужному элементу.

GUI Сценарии - это всегда процесс проб и ошибок; это поможет вам сосредоточиться на том, что попробовать.

...