AppleScript Tutorial: "Hello World" Your First AppleScript
24 February 2009
This tutorial will show you how to create your first AppleScript and will result in a simple AppleScript that displays a dialog box with the words “Hello World”.
This AppleScript tutorial intends to teache the reader some basic elements that can be used for future.
Elements that we will cover today are:
- Comments (How to place comments in your AppleScripts)
- Dialog (How to display a dialog box with a message)
- Reference Documents
Comments: Telling the world what you are trying to achieve
Comments are a key element of any coding as the comments in the code remind yourself what the code does and it also informs other users of the code as to what you are doing. Without Comments, code can be almost useless.Comments can be incorporated into AppleScripts in two ways
1) Using “(*” before the comment and closing the comment with “*)” This is a great way to include a multiline comment
2) Using “--“ at the start of a line of code. This will only comment-out the one line.
Example AppleScript Code:
(*
* AppleScript: Hello World
*
* Description: This AppleScript displays a Dialog box with the
* words "Hello World"
*
* Confirmed: This AppleScript works on
* Operating System: Mac OS X (Version 10.4.11)
*
* See more AppleScripts at http://applescript.thompson-solutions.com
*)
* AppleScript: Hello World
*
* Description: This AppleScript displays a Dialog box with the
* words "Hello World"
*
* Confirmed: This AppleScript works on
* Operating System: Mac OS X (Version 10.4.11)
*
* See more AppleScripts at http://applescript.thompson-solutions.com
*)
Creating your first complete AppleScript:
Now putting all the above elements together, you can create your first AppleScript.You can cut & paste the code below into your Script Editor or download the AppleScript using the link below.
Once the text is in your Script Editor, click on "Run" to execute the AppleScript. Example AppleScript Code:
(*
* AppleScript: Hello World
*
* Description: This AppleScript displays a Dialog box with the
* words "Hello World"
*
* Confirmed: This AppleScript works on
* Operating System: Mac OS X (Version 10.4.11)
*
* See more AppleScripts at http://applescript.thompson-solutions.com
*)
display dialog "Hello World"
* AppleScript: Hello World
*
* Description: This AppleScript displays a Dialog box with the
* words "Hello World"
*
* Confirmed: This AppleScript works on
* Operating System: Mac OS X (Version 10.4.11)
*
* See more AppleScripts at http://applescript.thompson-solutions.com
*)
display dialog "Hello World"
And that covers it. To download the complete AppleScript, click download AppleScript below. Download Example AppleScript
Reference Documents
To review the complete AppleScript Guide as well as other AppleScript Guides for MS Word, Excel, PowerPoint or Adobe Photoshop please review the “Reference Documents” page on this website.AppleScript Reference Documents
Best of luck with your AppleScripting adventures.
Regards,
Thompson-Solutions