AppleScript "not allowed to send keystrokes" fix

TL;DR:

  1. Make significant code changes and recompile
  2. Then remove and add from System Settings > Privacy & Security > Accessibility
  3. Then revert those code changes and recompile back to what you want your script to do.
  4. Then remove and add from System Settings > Privacy & Security > Accessibility


Hi,


I hope this helps someone.

After upgrading to Sonoma, my AppleScript that sent keystrokes broke.


This is the same question as Apple script is not allowed to send keyst… - Apple Community but the solution there didn't work for me so here's how I got it working again.


I ran the code from Script Editor and discovered that some GUI elements had changed. In fixing that, I had to change the code to list the GUI elements that exist so that I could pick one. Once I did that and updated the script code with the new GUI element name and recompiled, the keystrokes started working.


# For reference, this code lists GUI elements of current window.

# Copy the output into a text editor and find/replace , with ,<Line Break> so each element is on a separate line

tell front window of (first application process whose frontmost is true)

set uiElems to entire contents

end tell

Posted on Oct 23, 2023 9:56 AM

Reply

Similar questions

2 replies

AppleScript "not allowed to send keystrokes" fix

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.