Hi shaneakus,
I don’t have an airplay speaker, so don’t know where you’re trying to click, but here’s the process I use.
First, I might start with something like this:
tell application "iTunes"
activate
play playlist "Library"
end tell
tell application "System Events"
tell process "iTunes"
every UI element
end tell
end tell
result: {window “iTunes” of application process “iTunes” of application “System Events”, window “Equalizer” of application process “iTunes” of application “System Events”, menu bar 1 of application process “iTunes” of application “System Events”}
This gives you a list of ui elements of the iTunes application. Now suppose you want the ui elements of the iTunes window.
tell application "iTunes"
activate
play playlist "Library"
end tell
tell application "System Events"
tell process "iTunes"
tell window "iTunes"
every UI element
end tell
end tell
end tell
result: {button 1 of window “iTunes” of application process “iTunes” of application “System Events”, button 2 of window “iTunes” of application process “iTunes” of application “System Events”, button 3 of window “iTunes” of application process “iTunes” of application “System Events”, button 4 of window “iTunes” of application process “iTunes” of application “System Events”, button 5 of window “iTunes” of application process “iTunes” of application “System Events”, button 6 of window “iTunes” of application process “iTunes” of application “System Events”, button 7 of window “iTunes” of application process “iTunes” of application “System Events”, button 8 of window “iTunes” of application process “iTunes” of application “System Events”, slider 1 of window “iTunes” of application process “iTunes” of application “System Events”, scroll area 1 of window “iTunes” of application process “iTunes” of application “System Events”, text field 1 of window “iTunes” of application process “iTunes” of application “System Events”, button “1114 songs, 2.8 days, 8.99 GB” of window “iTunes” of application process “iTunes” of application “System Events”, splitter group 1 of window “iTunes” of application process “iTunes” of application “System Events”}
Then you find which one of these ui elements you want next. You keep going until you find the right ui element string of references for your tell blocks. This can be tedious work because oftentimes, the element you want to get to is placed in another ui element. Sometimes you need to try every branch.
Hope this helps. You can use the Accessibility Inspector in xCode to guide you in what kind of ui element you should be looking for.
gl,
Model: MBP
AppleScript: 2.2.3
Browser: Safari 536.26.17
Operating System: Mac OS X (10.8)