19

OK, this feels like an idiot question, but I'm stuck - I don't know the first thing about AppleScript. I have a .scpt file and I want to double-click it and just have it run, but instead every time I click, it opens up the AppleScript Editor. This feels like it should just be an option on the file, but I'm missing something obvious.

Please help me feel less dumb, thank you.

scottru
  • 5,280
  • 3
  • 21
  • 13

4 Answers4

35

From the “File” menu, choose “Export”; there’ll be a “File Format” dropdown underneath the file browser. To get a double-clickable application instead of a document, choose “Application”. This will produce a .app bundle like ordinary Mac applications (this will also let you package other resources with your script if you need to). You can choose “Run Only” or not; if you do, then anybody with just the .app won’t be able to edit your script further, since it’ll be compiled. (But if you’re saving a copy as the application, that might be what you want.)


Another option, as per an anonymous user on Ask Different, would be to save/export your file as a “Script” (.scpt) or “Script Bundle” (.scptd), save it in ~/Library/Scripts/, and check “Show Script menu in menu bar” in Script Editor’s preferences.


(If you’re running an old version of OS X, the first version of this answer has the information you’re looking for.)

Community
  • 1
  • 1
Antal Spector-Zabusky
  • 36,191
  • 7
  • 77
  • 140
  • 1
    I'd just like to add that the aforementioned "Save As..." menu is part of the AppleScript Editor app, which comes with your Mac. – David Grayson May 07 '12 at 20:55
  • 4
    On Mountain Lion (maybe also Lion) they replaced the "Save As..." with "Export..." – benregn Oct 25 '12 at 14:22
  • 1
    @Cawas: Thanks for keeping this up to date! I tweaked some things and removed the description of what the old stuff used to do, since it had become inaccurate. But this wouldn't have happened without your help :-) – Antal Spector-Zabusky Nov 20 '15 at 20:24
1

There's more than one way to do it; i have found this to be the simplest:

In sum, you create an Automator application and place your applescript inside it (easier than it sounds, and it's not a hack either--there's actually a specific Automator action for this). Then when you are finished, you select "File" from the menubar, next "Save As Application", then select a location. Now check there and you'll see the newly-created Automator icon (little white robot holding a grenade launcher).

You can do anything that you would ordinarily do with this application icon--double click to open, drag it to your dock, etc.

Appstorm has created an excellent step-by-step tutorial for building an applescript-embedded automator action. On the page i linked to, the tutorial author has also supplied an Automator script that you can download and use as a template.

doug
  • 69,080
  • 24
  • 165
  • 199
  • How is that simpler? "Open + Save as" versus "Create new Automator app + add new action + open script in script editor + copy + paste script in Automator + Save As". The only advantage of this method I can see is if you want it to appear in the Automator contextual menu in Finder, and if you do want to do that you have to add "Save As a Finder Plug-in" to the process. – stib Apr 12 '10 at 04:05
  • Agreed. I don't think that could get any more convoluted. Automator is completely ancillary to the original question (and the correctly accepted answer), – Philip Regan Apr 19 '10 at 15:04
1

While it's certainly not the simplest route, one benefit to running your script from Automator, as doug suggested, is that you can set a hotkey or keyboard shortcut to execute your script if you hide it in an Automator Service (OSX 10.6+). See:

http://blog.fosketts.net/2010/08/09/assign-keyboard-shortcut-applescript-automator-service/

esmail
  • 517
  • 11
  • 9
0

When you save a new script, a menu should appear asking what you want the file name to be, where it will be stored, any tags for it, and what script format you want it to be. There should be 4 scripts formats:

  1. Script
  2. Script Bundle
  3. Application
  4. Text

The script format you want to use would be "Application." This will turn it into a double-click application if its not in the dock.

Vojtech Ruzicka
  • 16,384
  • 15
  • 63
  • 66
Kayjek
  • 1
  • 6