When you say “Export”, are you referring to Script Debugger’s Export Run-Only command? Does your script have a run handler? DO you have the Show Startup applet option selected? Are you running the script on the machine that exported it or on another machine?
Perhaps start with a really simple test script that displays an alert. Once that’s working you can move on to your real script.
I have the script, then I do File -> Save As … , and then I select the application format. The export Run-only script option is disabled.
What do you mean by a “run handler” ? Do I have to modify the script to run it as an application ?
When I do the save as …, I have a check box named “Show startup screen”, and it’s selected.
And yes I am running the application and the script debugger script in the same machine.
I’m having exactly the same problem with an applescript. It runs fine in Script Debugger but (1) accessibility permissions screen won’t accept it most of the time. And, seemingly at random, accessibility permissions WILL accept the script…but even then, (2) the app will not run! On OS x 10.13.6. As per previous suggestion, I disabled debugging before saving as an app. Tim
Every single time you edit and save a Scriptable Application with GUI scripting in Script Debugger (or Script Editor) you will need to turn Accessibility back on.
I’ve noticed that if I try to set it on an application that has successfully run before (and has had accessibility turned on) and is then edited and saved, if I try to set accessibility before running it again, (trying to avoid getting that error message, it may not work). In the preference pane it looks like accessibility is on but System Preferences just doesn’t know that the app been edited and it may fail when it launches.)
It seems like after a script has been edited and saved the system needs to try and fail to run the script before I can turn accessibility on and expect it to always work.
A long time ago and far, far away, I had a script that wouldn’t run, much like yours. Copy and paste into a new document didn’t help. I decided the script file was corrupted and retyped the code by hand, which was a lot of lines. That fixed the problem.
If doing it today, I’d copy about half the script into a new window, compile and save it, then check for the problem. If it failed, I’d do the other half instead, if it checked out as okay. Then I’d keep adding about half of the remaining code (rechecking each time) until I isolated the corrupted section. That portion, I’d hand type, and then paste in any left over code.
There’s no way to know it your problem is the same as mine was, but it might be worth a try.
@TimBurton Thank you for sending the applet your are trying to export.
I notice that, in the version you sent me, you have Script Debugger debugging enabled (hence the ladybug icon in the applet’s icon). Firstly, disable debugging by selecting the Disable Debugging command from Script Debugger’s Script menu:
NOTE: If you leave debugging enabled, your script will continue to execute within Script Debugger, even when you launch you applet from the Finder or Dock. Script Debugger’s script window will look like this:
I re-created the script as an applet and it ran fine till yesterday.
I then updated the code with some statements inside a catch and now when I run it it always complains that it has no accessibility permission. I go into system preferences and turn it on, then re-run the applet and it the same error occurs. Now it always throws the same error even after I turn on accessibility for that applet.