title: Sending keystrokes in Applescript via Automator in any application
body: <p>I setup an Applescript quick action in Automator to leave a zoom meeting. No matter what application is in the forefront, I would like to check if zoom is running and if so, leave the meeting.</p>
  <pre><code>set appName to &quot;Zoom.us&quot;
  
  if application appName is running then
      tell application id (id of application appName)
          activate
      end tell
      tell application &quot;System Events&quot;
          keystroke &quot;w&quot; using command down
          keystroke tab
          keystroke return
      end tell
  end if
  </code></pre>
  <p>It works! The problem is, if I'm in a zoom meeting and another app is in the forefront, I have to get permission from system preferences for that app to access system preferences. Like if I'm in Chrome, I have to allow Chrome to send keystrokes. Then, Chrome will always work.</p>
  <p>I have to do this for every single possible app. Is there a way to get keystrokes in there without going thru this security stuff in Big Sur? I don't mind bringing up zoom to the forefront.</p>