applescript

AppleScript User Interaction

Syntax#

  • display dialog text [default answer text] [hidden answer boolean] [buttons list of text] [default button text/integer] [cancel button text/integer] [with title text] [with icon text/integer/stop/‌note/‌caution/file] [giving up after integer]
  • display alert text [message text] [as critical/informational/warning] [buttons list of text] [default button text/integer] [cancel button text/integer] [giving up after integer]
  • display notification text [with title text] [subtitle text] [sound name text]
  • choose file [with prompt text] [of type text] [default location alias] [invisibles boolean] [multiple selections allowed boolean] [showing package contents boolean]
  • choose folder [with prompt text] [default location alias] [invisibles boolean] [multiple selections allowed boolean] [showing package contents boolean]
  • choose from list [with title text] [with prompt text] [default items list of text/number] [OK button name text] [cancel button name text] [multiple selections allowed boolean] [empty selection allowed boolean]
  • choose URL [showing list of Web/‌FTP/‌Telnet/‌File/‌News/‌Directory/‌Media/‌Remote] [editable URL boolean]
  • choose color [default color RGB color]

Remarks#

AppleScript User Interaction is part of Standard Additions. You can find the full documentation in the dictionary StandardAdditions.sdef through Script Editor’s Open Dictionary.

Display a dialog or alert

AppleScript can display dialogs and alerts to the user. Dialogs are for optionally requesting user input.

display dialog "Hello World"
display alert "Hello World"

You can customise the buttons of either using buttons and passing a list of text.

display dialog "Hello World" buttons {"button one", "button two", "button three"}

Upon clicking a button, the button clicked is returned:

{button returned:"button one"}

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow