Exported app does nothing

Hi,

I have a script that I run successfully within script debugger. I then exported it into an app file.
When I run the app file, the icon appears on the dock but the script seems to be doing nothing.

It should run an application in my applications folder and drive it with system events.
What could be the problem ?

Thanks

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.

Thanks

Make sure you disable debugging when saving as an application. If you have debugging enabled, then the script will run within Script Debugger when you double-click it from the Finder.

If you have code outside a handler definition, then you have a run handler. I was worried you had an on idle handler without having selected the Stay Open applet option.

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.

Yes, I learned that early on. Every edit/save as app requires setting perms again.

Have you tried copying the contents of the script into a new empty document, and saving that as an application?

Yes, did that. Same result

Hi Tim,

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.

Regards,
Stan C.

Or you could copy the script’s contents into BBEdit, Text Wrangler or some other plain text editor, then paste that back into a new script document. That might work too.

If this is the same script you sent to support, then debugging has not been disabled.

@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:

And then re-save your script.

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:

Yes, that works fine now.

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.

Try turning off debugging before saving as an app

1 Like

That did it. Thanks a lot.

1 Like