0

System: macOS Monterey 12.0.1

I'm having an issue with my automation using osascript and I can't seem to find the way to solve it. I want to run a osascript code that will tell the System Events application to perform some actions.

Currently, when I try to run something as simple as:

tell application "System Events"
    keystroke "echo hi"
end tell

I always get the current error:

execution error: Not authorised to send Apple events to System Events. (-1743

I've read around that is related to the Accessibility and Automation privacy settings in MacOs. The real issue that I'm having is that the Automation setting gets unchecked on its own each time I run this script! If i run the script and go back to settings, the checkbox for Terminal > System Events.app is unchecked and I haven't unchecked it...

  • I've tried to do a reset for SystemEvents running tccutil reset AppleEvents and setting again the privacy setting. Nothing.
  • I erased the Accessibility and Automation settings (unlocking the settings lock and locking it again). No result, the moment that I run the osascript in my Terminal the Automation setting gets unchecked again.
  • I've also killed the Apple Events process in case it was stuck, same result.

Moreover I've read that Apple should raise the typical "Confirmation pop-up" to allow the use of automation with my Terminal but no such thing has happened to me.

Does anyone have any advice or alternative I could try? I do not know what else to do and people insist on retrying several times the "erase Accessibility setting and add it again" but I've done it like 8 times already...

Meru
  • 77
  • 13

0 Answers0