为什么 AppleScript 显示对话框在编辑器和 Automator 之间的行为如此不同?

发布于 2024-10-11 12:47:52 字数 702 浏览 3 评论 0原文

例如,为什么这个脚本可以在 AppleScript Editor 上运行,但不能在 Automator 上运行?

显示对话框“大量文本只是为了中断到第 4 行,无论继续...还有多少...啊...那里!”标题为“只是一个测试”按钮{“取消”、“卸载”、“继续”} 默认按钮 3 带有图标警告

在 Automator 上注释掉标题之后的所有内容,这是我得到的区别:

alt text

想要 标题 和如果可能的话,超过3行,但是这些并不是我在过去一个小时中看到的关于editorautomator。图标是另一个。

在本例中,我在 Automator 中尝试时遇到的错误是这样的:

Syntax Error

录制,这里的问题是:

  1. 为什么?为什么哦苹果,为什么?
  2. 有什么办法至少能让标题发挥作用吗?

For instance, why this script works on AppleScript Editor but not Automator?

display dialog "a lot of text just to break to line 4 whatever continuing... few more... argh... there!" with title "just a test" buttons {"Cancel", "Uninstall", "Continue"} default button 3 with icon caution

Commenting out everything after the title just on Automator, this is the difference I get:

alt text

I want the title and more than 3 lines if possible, but those are not the only weird inconsistent behaviors I've seem in the past hour about applescript between editor and automator. The icon is another one.

In the instance, the error I get for trying it in Automator is this:

Syntax Error

Recording, questions here are:

  1. Why? Why oh Apple, why?
  2. Any way to at least make the title work?

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

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

发布评论

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

评论(1

攒一口袋星星 2024-10-18 12:47:52

问题的原因是 Automator 导入了 Applescript Studio 术语,它重新定义了显示对话框作为面板套件;该版本没有 with title 参数。您可以通过使用 Applescript 编辑器打开 Automator 来进行检查。 (使用文件→打开字典...)我同意这是苹果的一个愚蠢的决定:(

你可以通过在 Automator 内部使用来规避这个问题

using terms from application "Finder"
    display dialog "a lot of text just to break to line 4 whatever continuing... few more... argh... there!" with title "just a test" buttons {"Cancel", "Uninstall", "Continue"} default button 3 with icon caution
end using terms from

;这告诉 Applescript 的编译器发出 显示对话框 命令调用标准定义。

The cause of the problem is that Automator imports the terminologies of Applescript Studio, which redefines redefines display dialog as part of the Panel Suite; that version doesn't have the with title parameter. You can check that by opening Automator using the Applescript editor. (Use File→Open Dictionary...) I agree that this is a stupid decision by Apple :(

You can circumvent this problem by using

using terms from application "Finder"
    display dialog "a lot of text just to break to line 4 whatever continuing... few more... argh... there!" with title "just a test" buttons {"Cancel", "Uninstall", "Continue"} default button 3 with icon caution
end using terms from

from inside Automator; this tells Applescript's compiler to make the display dialog command call the standard definition.

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