title: How to script a button click based on Label or Identifier
body: <p>I'm writing a script in AppleScript that ends with a button press in an application. The issue, however, is that the button has no Attribute Title. I've run Accessibility Inspector and UI Browser over it and the AXTitle is &lt;empty string&gt;.</p>
  
  <p>I can call the button by its number, but everyone on my team has this application set up slightly differently based on their own workflow and the stupid button has a different identifying number depending on where the window is. The window can be a detached pop-up, or attached to the main application window on either the left or the right. All three options yield a different index address.
  <br><br><br>
  Button Index when attached to the left:</p>
  
  <pre><code>tell application "System Events" to tell process "Application Name"
      click button 8 of splitter group 1 of front window of application 
      process "Application Name" of application "System Events"
  end tell
  </code></pre>
  
  <p><br><br><br>
  Button Index when attached to the right:</p>
  
  <pre><code>tell application "System Events" to tell process "Application Name"
      click button 9 of splitter group 1 of front window of application 
      process "Application Name" of application "System Events"
  end tell
  </code></pre>
  
  <p><br><br><br>
  Button Index when window is detached and floating:</p>
  
  <pre><code>tell application "System Events" to tell process "Application Name"
      click button 8 of front window of application process "Application    
      Name" of application "System Events"
  end tell
  </code></pre>
  
  <p><br><br><br>
  The constant between the locations is the button label and the button identifier, but I'm having trouble getting script editor to recognize the button based on the Identifier or Prepared Response. I don't know if it's just not possible or if I'm simply writing the code wrong.</p>
  
  <p>When I try to use either the Label or Identifier I get the errors</p>
  
  <pre><code>click button "Prepared Response" of front window
  </code></pre>
  
  <p><strong>Script Error</strong> System Events got an error: Can’t get button "Prepared Response" of window 1 of process "Application Name".</p>
  
  <pre><code>click button "_NS:667" of front window
  </code></pre>
  
  <p><strong>Script Error</strong> System Events got an error: Can’t get button "_NS:667" of window 1 of process "Application Name".</p>
  
  <pre><code>click button with "Prepared Response" of front window
  </code></pre>
  
  <p><strong>Syntax Error</strong> Expected “into”, variable name, class name, other parameter name or property but found “"”.</p>
  
  <pre><code>click button with label "Prepared Response" of front window
  </code></pre>
  
  <p><strong>Syntax Error</strong> Expected “given”, “with”, “without”, other parameter name, etc. but found “"”.
  <br><br><br>
  The only two restrictions are that the code has to be AppleScript - not Javascript - and that I can't require my team members to install an application</p>