AppleScript .app not working

I made a simple script to auto-fill login info to access my school's web-portal. The script runs just fine when launched from the script editor, but not when launched as an app. Instead, I get :

"Not allowed to send Apple events to System Events. (-1743)"

Script editor and my app are in the Accessibility list in System Preferences but my app doesn't appear in automations list, even after resetting System Events authorizations with the following command in Terminal:
Code Block
tccutil reset AppleEvents

I don't have any background with coding so any help would be appreciated !
Here is my code if it helps :

Code Block
set USERNAME to "XXXXXX"
set PW to "XXXXXX"
tell application "Safari"
activate
open location "https://ector.strasbourg.archi.fr/public/perimetre"
end tell
delay 1
tell application "System Events" to tell process "Safari"
keystroke tab
delay 0.2
keystroke USERNAME
delay 0.2
keystroke return
end tell
delay 3
tell application "System Events" to tell process "Safari"
keystroke USERNAME
delay 0.2
keystroke tab
delay 0.2
keystroke PW
delay 0.2
keystroke return
end tell


The script runs just fine when launched from the script editor, but
not when launched as an app.

What version of macOS are you working on?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
AppleScript .app not working
 
 
Q