I don't know if the term "GUI element" is the correct one, but I have a macro that clicks the Google Drive menu bar icon, then clicks another button when the menu is visible, then another one. Is it possible to pause the macro until those elements are available, without relying on the Found Image action?
Right now I have a script, but sometimes it throws me an error like this:
Execute an AppleScript failed with script error: text-script:114:207: execution error: System Events got an error: Can’t get group 3 of UI element 1 of window 1 of process "Google Drive". Invalid index. (-1719)
So I'm assuming it's because it's not being fast enough. I could increase the delay, but I was wondering if I could pause the macro and wait for each element to be visible or available?
Here's the script
tell application "System Events"
tell process "Google Drive"
click menu bar item 1 of menu bar 1
delay 0.2
click pop up button 1 of group 1 of group 1 of group 1 of group 3 of UI element 1 of window 1
delay 0.2
click menu item 4 of menu 1 of group 1 of group 2 of group 1 of group 3 of group 1 of UI element 1 of window 1
delay 0.2
click menu bar item 1 of menu bar 1
end tell
end tell
For example this is the icon:
Then when the window opens up, this is the icon I need to click:
Then after that, I click the Resume syncing / Pause syncing
I found this topic, tested the script using Safari and it indeed showed me a list of elements:
Script:
tell application "System Events"
tell process "Safari"
set visible to true
return every UI element of front window
return name of every UI element of front window
end tell
end tell
So I would guess that the menu bar can also be scanned and check if element XYZ is visible or not?