Why AppleScript display dialog behaves so differently between Editor and Automator?

StackOverflow https://stackoverflow.com/questions/4646047

  •  09-10-2019
  •  | 
  •  

문제

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?
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top