I’d like to iterate through every element on an iTunes window and try to click on each element.
I’d also like to write to a text file showing each element that I’ve clicked.
The code that I wrote below isn’t working. Specifically, I get the error process “iTunes” doesn’t understand the click_an_element message.
Thoughts on what I’m doing wrong?
Thanks!!
tell application "iTunes" to activate
tell application "System Events"
tell process "iTunes"
set elements to get entire contents of window "iTunes"
repeat with i from 1 to (length of elements)
set ele to item i of elements
click_an_element(ele)
show_what_you_clicked(ele)
end repeat
end tell
end tell
-------handlers------------
to click_an_element(an_element)
tell application "iTunes" to activate
tell application "System Events"
tell process "iTunes"
try
click an_element
end try
end tell
end tell
end click_an_element
to show_what_you_clicked(thing_to_type)
tell application "TextEdit" to activate
tell application "System Events"
tell process "TextEdit"
keystroke thing_to_type
key code 36
end tell
end tell
end show_what_you_clicked
your out of scope it thinks click_an_element is an itunes function
you need to add “my” to that call
Edit: since a had some time over lunch I play around with this a little bit had to turn off clicking because it was clinking minimize button then not giving access to the other items