title: Use AppleScript to list the names of all UI elements in a window (GUI scripting)
body: <p>One line summary - I'm looking for a way to get AppleScript itself to reveal the name it expects a specific piece of window content (UI element) to be referred to as in a "tell" statement.</p>
  
  <p>How do I get AppleScript to list the name it wants me to use to refer to a window's contents?</p>
  
  <p>for example I can say <code>tell current application to tell its front window's list 1 to ...</code> </p>
  
  <p>I'm trying to find out the term like "list 1" for all of the window's contents so I can cross-reference it with the list from Accessibility Inspector.. </p>
  
  <p>I tried this code but the first line generates an error saying "error "Can’t make names of «class ects» of window 1 of «class prcs» \"iTunes\" of application \"System Events\" into type string." number -1700 from names of «class ects» of window 1 of «class prcs» "iTunes" to string"</p>
  
  <pre><code>tell application "System Events" to tell process "iTunes" to set elementNames to the names of the entire contents of its front window as string
  tell application "TextEdit"
      activate
      make new document at the front
      set the text of the front document to elementNames
      set WrapToWindow to text 2 thru -1 of (localized string "&amp;Wrap to Window")
  end tell
  </code></pre>