Script Editor not allowed to send Keystrokes

On MacOS High Serria I use an AppleScript in a Xojo project to execute Keystrokes. When I run the same project in OS Mojave it come up with an Error saying “System Events got an Error: Script Editor is not Allowed to send Keystrokes”. If I go into System Preferences / Security & Privacy / Accessibility and remove Script then reinstall it will work for one time. I have to continue doing this for it to work.
Is there any way to make this work correctly or are there other ways to do Keystrokes (Xojo only ) or maybe a Declare.

27 inch IMac running MacOS Mojave version 10.14.6
Any help would be Greatly Appreciated.

Your app needs to have usage string in info.plist for controlling computer.
And if you code sign, you may need entitlements.
And of course user needs to allow it.

Do you know where I can read about the usage string and info.plist in more detail?
Thank You for your Reply.

Have you seen examples from MBS Xojo Plugins?

For our AppleScript examples, we include an info.plist file.
That one includes only an entry for NSAppleEventsUsageDescription.
You could use this one as base.


Thanks, I will check these places.

Does this example use System Events to simulate a key press? If so, it will not be allowed on the App Store.

Modern “Security” certainly makes this far more difficult that it used to be.

Yes this does use System Events to simulate a keypress. This app is just for my personal use. I would like if there was some way to stop the error window coming up.