tell application "System Events"
tell process "Messages"
if exists UI element 3 of group 1 of group 1 of window 1 then
but it can’t find UI element 3.
I notice UI element 3 is within parenthesis in the UI Browser while the other elements’ type is outside. Is that the problem? How do I check for this element?
I’m not a facetime user so I don’t have anything to say on that aspect but the element in question must exist when the script runs. It could be that the progress bar only exists when it’s busy progressing.
It is Messages.app (I know it says Facetime in the image). The progress bar is there because the message is stuck on the transfer.
I think I have hit some rate limit, both on iMessages as well as SMSs. That is the reason for my question: I want to detect this progress bar and if it is there for more than a few seconds I want to break (in my situation the progress bar is there for hours).
I think you can emulate this by sending an SMS (not iMessage) when your phone is in flight mode. In that situation I think this progress bar will be there for at least several minutes.
{group 1 of group 1 of group 1 of window "[phonenumber]" of application process "Messages" of application "System Events"}
I also tried adding/removing one level of group:
get every UI element of group 1 of group 1 of group 1 of window 1 of process "Messages"
--> {group 1 of group 1 of group 1 of group 1 of window "[phonenumber]" of application process "Messages"}
get every UI element of group 1 of window 1 of process "Messages"
--> {group 1 of group 1 of window "[phonenumber]" of application process "Messages"}
So just more levels of groups.
You can emulate the behaviour I see by turning off the computer’s network and then try to send an SMS/iMessage. Now the progress bar will appear. How do I detect that?
tell application "System Events"
tell process "Messages"
repeat
if exists UI element 3 of group 2 of group 2 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of window 1 then
beep
delay 2
else
say "Done!"
exit repeat
end if
end repeat
end tell
end tell
It will keep beeping while the Progress Bar exists. Then it will say ‘Done’ when it goes away
or even shorter…
tell application "System Events" to tell process "Messages"
repeat while exists UI element 3 of group 2 of group 2 of group 1 of group 1 of group 1 of group 1 of group 1 of group 1 of window 1
beep
delay 2
end repeat
say "Done!"
end tell
“UI Browser” is old.
Apple’s own “Accessibility Inspector” also gives bad results
Apple, as of late, has quite a few programs that don’t work properly with GUI scripting. Sometimes I have to keep looping thru groups inside groups till it finally finds the item I’m looking for. I have a script that will search for these things for me recursively.