【发布时间】:2011-04-12 11:55:01
【问题描述】:
为了运行我的 AppleScript 程序,我必须打开它并选择“运行”。我希望程序在我单击它时运行。我试图编译它,但它似乎没有任何区别或创建一个新文件。
【问题讨论】:
标签: osx-snow-leopard applescript executable
为了运行我的 AppleScript 程序,我必须打开它并选择“运行”。我希望程序在我单击它时运行。我试图编译它,但它似乎没有任何区别或创建一个新文件。
【问题讨论】:
标签: osx-snow-leopard applescript executable
如果保存正确,则为可点击的应用程序:
# 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
【讨论】:
当您保存 AppleScript 时,您可以选择将其保存为应用程序,这将使其可执行。
【讨论】:
如果您正在考虑 regulus6633 提到的第一个方法,您可以使用 Quicksilver、TextExpander、osascript 等启动 AppleScripts。要制作应用程序,您只需使用方法 2。
【讨论】:
两种方式。
1) 我的首选方法是激活脚本菜单。如果您使用的是 10.6,请打开 AppleScript Editor。打开首选项并在“常规”选项卡下单击“在菜单栏中显示脚本菜单”。现在,您将在屏幕右上角的菜单栏部分看到一个新图标。您可以从该菜单运行任何 AppleScript。 (在 10.5 中,过程有所不同,但您可以 google 查找路线)。要在该菜单中放置一个 AppleScript,只需转到文件夹 ~/Library/Scripts 并将您的 AppleScript 添加到其中。从 Script 菜单中选择您的 applescript 将运行它。
2) 从 AppleScript 编辑器的文件菜单中选择“另存为...”,并将“文件格式”设置为应用程序。然后它就像任何其他应用程序一样工作......只需双击它即可运行它。
注意:如果您使用脚本菜单...选择一个脚本将运行它。如果您想在 AppleScript Editor 中打开脚本进行编辑,请在选择脚本时按住 option 键。
【讨论】: