I am currently making an AppleScript and would like to know how to do the following things.

  • Display text in the center of a display dialog
  • How to create a new line inside the dialog

2 Answers 2


To create a second line use \n or just hit enter when you want the new line:

display dialog "Test\nTest2"


display dialog "Test

About the center alignment, I think that is not possible.

  • 1
    @user121028 just the same. "Hello, \n" & currentuser & "!\n"...
    – jherran
    Commented Jun 14, 2015 at 10:22

You can use CocoaAppleScript to do this. Create one by going into Script Editor's "New from Template" menu in the File menu, and "Cocoa-AppleScript Applet.app". Modify html_data's HTML code to get it to be how you want it. Try it out!:

set alert to current application's NSAlert's new
set alert's messageText to ""
set text_field to current application's NSTextField's alloc's initWithFrame:NSMakeRect(0, 0, 300, 88)
set text_field's drawsBackground to false
set text_field's editable to false
set text_field's bezeled to false
set html_data to (current application's NSString's stringWithString:("<center><font size=\"80\">Welcome!<br>Another welcome!</font></center>"))'s dataUsingEncoding:(current application's NSUTF8StringEncoding)
set text_field's attributedStringValue to (current application's NSAttributedString's alloc's initWithHTML:html_data documentAttributes:(current application's NSDictionary's dictionaryWithObject:(current application's NSFont's fontWithName:"Palatino-Roman" |size|:12) forKey:(current application's NSFontAttributeName)))
set alert's accessoryView to text_field
alert's runModal
  • Thanks, it works, but it is for my purpose too long and too complex.
    – user121028
    Commented Jun 14, 2015 at 9:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .