Error Message: App is not allowed to send keystrokes

Issue:
ERROR Message: “is not allowed to send keystrokes”

Script:

--MyApp.app
tell application "Safari"
	activate
	delay 3
	activate
	tell application "System Events"
		keystroke "w" using {command down} -- closes window
	end tell
end tell

Troubleshooting:
OS Tests

  • this script / app does work in Monterey but doesn’t work in Ventura.

Script Editor
In script editor it runs without error message but not as an App

Setting Setup

  • Permissions for script editor in Privacy (+ Added to ) >
  • Accessibility
  • Automation
  • Full Disk Access

As an App

  • export
  • save as an app
  • open app
  • get the is not allowed to send keystrokes

You shouldn’t have a tell application inside a tell application.

What you can do is a ‘tell application “System Event” ‘
And inside that have a ‘tell application process “Safari” ‘
Then you send the keystroke.

The keystroke command likes to have a process to target

1 Like

If this is what you’re suggesting this doesn’t even compile.

Another note:

  • this script / app does work in Monterey but doesn’t work in Venture.

Odd that it worked in Monterey but this does work in Ventura too now.

thanks!

thanks for this insight.