title: Cocoa: get and change text and selection in third-party apps (without simulating key presses nor using accessibility API)
body: <p>I'm writing a Mac utility app in which I would like to manipulate text and selection in third-party apps. I found two methods for doing so:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/10734349/simulate-keypress-for-system-wide-hotkeys">Simulating key presses</a></li>
  <li><a href="https://developer.apple.com/library/mac/documentation/ApplicationServices/Reference/AXUIElement_header_reference/index.html" rel="nofollow noreferrer">Using the accessibility API</a></li>
  </ul>
  
  <p>However, they both have major drawbacks and I'm wondering if there are any other methods I could explore?</p>