如何从 AppleScript 制作可执行程序

发布于 2024-09-18 20:07:04 字数 84 浏览 2 评论 0原文

为了运行我的 AppleScript 程序,我必须打开它并选择“运行”。我希望该程序在我单击它时运行。我尝试编译它,但它似乎没有产生任何影响或创建新文件。

In order to run my AppleScript 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

横笛休吹塞上声 2024-09-25 20:07:04

2种方式。

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

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

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

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.

孤檠 2024-09-25 20:07:04

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

When you are saving your AppleScript, you can choose to save it as an application, which will make it executable.

丿*梦醉红颜 2024-09-25 20:07:04

如果您正在考虑使用 regulus6633 提到的第一个方法,您可以使用 Quicksilver、TextExpander、osascript 等启动 AppleScripts。要制作应用程序,您只需使用方法 2。

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.

聊慰 2024-09-25 20:07:04

如果保存正确的话,一个可点击的应用程序:

# 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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文