如何从AppleScript制作可执行程序

时间:2010-09-15 04:29:21

标签: osx-snow-leopard applescript executable

为了运行我的AppleScript程序,我必须打开它并选择“运行”。我希望程序在我点击它时运行。我试图编译它,但它似乎没有区别或创建一个新文件。

4 个答案:

答案 0 :(得分:19)

2种方式。

1)我首选的方法是激活“脚本”菜单。如果您使用的是10.6,请打开AppleScript编辑器。打开首选项,然后在“常规”选项卡下单击“在菜单栏中显示脚本菜单”。现在,您将在屏幕右上角的菜单栏部分中看到一个新图标。您可以从该菜单运行任何AppleScript。 (在10.5中,过程不同,但您可以谷歌指示)。要将一个AppleScript放在该菜单中,只需转到〜/ Library / Scripts文件夹并将你的applescript添加到它。从“脚本”菜单中选择您的AppleScript将运行它。

2)AppleScript Editor中的文件菜单中的“另存为...”,并将“文件格式”设置为应用程序。然后它就像任何其他应用程序一样......只需双击它即可运行它。

注意:如果使用“脚本”菜单...选择脚本将运行它。如果要在AppleScript编辑器中打开脚本进行编辑,请在选择脚本时按住选项键。

答案 1 :(得分:7)

当您保存AppleScript时,您可以选择将其保存为应用程序,这将使其可执行。

答案 2 :(得分:3)

如果您正在考虑像regulus6633提到的第一个方法,您可以使用Quicksilver,TextExpander,osascript和其他一些方法启动AppleScripts。要创建应用程序,只需使用方法2.

答案 3 :(得分:-1)

一个可点击的应用,如果保存得当:

# 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