Very curious as to why this works (the context is an open and activated/frontmost Safari window displaying the "Customize Toolbar" sheet):
tell application "System Events" tell process "Safari" set entireContents to entire contents of sheet 1 of front window repeat with x in entireContents if class of x is image and description of x contains "My Extension" then set targetExtIconPos to position of image 1 of x else if class of x is image and description of x is "default set of toolbar items" then set defaultToolbarPos to position of x end if end repeat end tell end tell
repeat with x in entireContents to
repeat with x in entire contents of sheet 1 of front window throws an error (and does so even if parenthesis are utilized as in
repeat with x in (entire contents of sheet 1 of front window))?
The error I get is:
execution error: System Events got an error: Can’t make item 1 of entire contents of sheet 1 of window 1 of process "Safari" into type specifier. (-1700)
This caused alot of headache before I randomly found it would work if I just assigned it to a var first…
Also is there a way to achieve what I am attempting here without using a loop at all? I feel like there is a way, but the syntax is just awfully hard and complex to figure out and nail down.