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)