How to make an executable program from AppleScript
In order to run my Appl开发者_如何学运维eScript program I have to open it up and select "run." I want the program to just run when I click on it. I tried to compile it, but it didn't seem to make a difference or create a new file.
2 ways.
1) my preferred method is to activate the Script menu. If you're using 10.6, open AppleScript Editor. Open the preferences and under the General tab click "Show Script menu in Menu Bar". Now you'll get a new icon in the menu bar section at the top-right of your screen. You can run any applescript from that menu. (in 10.5 the process is different but you can google for directions). To put an applescript in that menu just go to the folder ~/Library/Scripts and add your applescript to it. Choosing your applescript from the Script menu will run it.
2) "Save As..." from the file menu in AppleScript Editor and set the "File Format" to application. Then it works like any other application... just double-click it to run it.
NOTE: if you use the Script menu... selecting a script will run it. If you want to instead open the script in AppleScript Editor for editing then hold the option key down while choosing the script.
When you are saving your AppleScript, you can choose to save it as an application, which will make it executable.
If you were considering methods like the first one mentioned by regulus6633 you can launch AppleScripts with Quicksilver, TextExpander, osascript and some other. To make an application you just use the method 2.
A clickable app if saved properly:
# Old post but this answer may save someone a lot of time.
# In Applescript, make a new script with the following lines (see below).
# Then, after selecting the ''Stay open after run handler'' option,
# save as File Format ''application'' .
# This is the simplest version of a standalone app.
# It is essentially a directory with a Scripts folder and a compiled Applet in it.
# Right click it's icon in the Finder to open the package for a peek inside.
# Other internal items such as icons, files, and other scripts may be added and interacted with.
on run
#put something here which happens once at startup.
say "I am running."
end run
on idle
#put something here which happens repeatedly.
say "I am waiting."
return 2 --repeats every 2 seconds. (0 will default to 30 seconds)
end idle
on quit
#put something here which happens at the end of the program's use.
say "I am quitting."
continue quit
end quit
# To accept dropped item's, embed your handlers between tags before saving as shown below here. Enjoy!
on open droppedItems
beep --or some other cool thing.
end open
精彩评论