【问题标题】:Why AppleScript display dialog behaves so differently between Editor and Automator?为什么 AppleScript 显示对话框在 Editor 和 Automator 之间的行为如此不同?
【发布时间】:2011-01-10 10:55:56
【问题描述】:

例如,为什么这个脚本适用于 AppleScript Editor 而不是 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

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

想要 title3 行 如果可能的话,但这些并不是我出现的唯一奇怪的不一致行为editorautomator 之间关于 applescript 的过去一个小时。图标是另一个。

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

录音,这里的问题是:

  1. 为什么?为什么哦 Apple,为什么?
  2. 有什么方法可以至少使 title 起作用?

【问题讨论】:

  • 在您显示的两个对话框中看起来都很难看。我不明白这个问题...
  • @Cody 这很丑,因为它只是一个测试。如果您尝试运行代码,也许您会明白...我不确定如何使其更清晰。
  • 我试过了,但 Visual Studio 不会编译它。我现在不在 Mac 前。不过,我仍然认为你的问题没有意义。所以您发现 Automator 的行为有时与 AppleScript 不一致?这并不让我感到惊讶,因为 AppleScript 早在 18 年前就问世了,早在 Automator 之前。没错,AppleScript 不支持超过 3-4 行的消息框。想办法少说多说。
  • @Cody Gray:如果您了解 AppleScript 的内部工作原理,您可以理解并立即知道行为的原因 :)

标签: applescript automator


【解决方案1】:

问题的原因是Automator导入了terminologies of Applescript Studio,它重新定义了display dialog作为Panel Suite的一部分;该版本没有with title 参数。您可以通过使用 Applescript 编辑器打开 Automator 来检查。 (使用文件→打开字典...)我同意这是 Apple 的愚蠢决定:(

你可以通过使用来规避这个问题

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

来自 Automator 内部;这告诉 Applescript 的编译器让 display dialog 命令调用标准定义。

【讨论】:

  • 非常感谢!我已经使用 Applescript Editor 解决了所有问题,并将文件保存为 Application! :D 但你的答案是完美的! ;)
  • 我说完美无瑕?我的意思是重新定义重新定义。 :D
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-08-22
  • 1970-01-01
  • 2020-11-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多