AppleScript difference between scpt and app

I have the following Applescript XY.scpt which runs perfect from within the ScriptEditor. But after exporting it to an App (XY.app) it breaks with the message "System Events got an error: XY not allowed assistive access." (-1719)".


This is in Ventura 13.3 and the script XY is allowed for Accessibility and Automation in System Settings Security&Privacy.


set CR to ASCII character 13
set my0xC9 to ASCII character 201
tell application "Notes"
	activate
	set uiScript to "click menu item \"export as pdf" & my0xC9 & "\" of menu 1 of menu bar item \"File\" of menu bar 1 of application process \"Notes\""
	run script "tell application \"System Events\" " & CR & uiScript & CR & " end tell"
end tell


Thanks for your help, ideas and input!




Mac mini (M1, 2020)

Posted on Apr 5, 2023 12:38 PM

Reply
Question marked as Top-ranking reply

Posted on Apr 10, 2023 4:19 AM

After my investigations and some important help from Apple I would like to share my insights. I had problems to create an app from a script (Applescript). I could create the app but never run it successfully. Here are the steps to solve this problem:

  1. You have to get a certificate to sign the app with. This certificate can be obtained through the Apple Developer Program (paid) or free for limited use in Xcode > Settings > Accounts.
  2. When exporting from the Script Editor you have to choose Application (dropdown in File Format) and the received certificate from step 1. above (dropdown in Code Sign:)
  3. And last you have to permit your new app the needed rights. On the first run of the app you are asked to grant what your app needs. This is in "System Settings" > "Privacy & Security" > e.g. "Accessibility" and others (depending on your script).


I hope Apple will change this policy and also permit running local apps without signing them. But until then, the above steps are hopefully helpful!

Similar questions

1 reply
Question marked as Top-ranking reply

Apr 10, 2023 4:19 AM in response to ttaallff

After my investigations and some important help from Apple I would like to share my insights. I had problems to create an app from a script (Applescript). I could create the app but never run it successfully. Here are the steps to solve this problem:

  1. You have to get a certificate to sign the app with. This certificate can be obtained through the Apple Developer Program (paid) or free for limited use in Xcode > Settings > Accounts.
  2. When exporting from the Script Editor you have to choose Application (dropdown in File Format) and the received certificate from step 1. above (dropdown in Code Sign:)
  3. And last you have to permit your new app the needed rights. On the first run of the app you are asked to grant what your app needs. This is in "System Settings" > "Privacy & Security" > e.g. "Accessibility" and others (depending on your script).


I hope Apple will change this policy and also permit running local apps without signing them. But until then, the above steps are hopefully helpful!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

AppleScript difference between scpt and app

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