hands on 2002
Do it with AppleScript
By Fred Teo, March 06, 2002

AppleScript is Mac's hidden treasure. Find and use it to make your computing more convenient.


AppleScript - an often unrecognised but powerful feature of the Macintosh system - is a scripting language that allows us to control and automate many daily routines. As with any scripting program, AppleScript requires some programming skill but it is easy to learn.
Apple has provided Mac users with many useful tools to help them make use of AppleScript.

One of the most important tools while using AppleScript in Mac OS X is the ScriptMenu (www.apple.com/AppleScript/macosx/script_menu/).

This little application lets you launch not only scripts written in AppleScript, but also Perl and Shell script. Download it into your Applications folder and drag the ScriptMenu icon to the menu bar.

Writing applescript Programming in any language will take a long time to explain. Here I will simply make use of AppleScript to help you save time with some of the stuff you do every day, such as checking websites for news updates, stock quotes, football results and so on.

To automate this repetitive process, let's write an Applescript. With AppleScript, you can automate routine functions, such as checking your favourite websites.

With ScriptMenu installed, click on the ScriptMenu icon (top right on the menu bar) and select Basics>Open Script Editor. This will launch Script Editor, with a new "untitled" script that you will work on to write your very first script.



The "untitled" script window is divided into two panes: the Description pane above the Record, Stop, Play and Check Syntax button, and the Code pane.

First, let the script know what you want it to do, that is, open Internet Explorer. You command the script to "talk to" Internet Explorer in the first line of code, and the second line to launch by using the word "Activate".

On the third line, the script will tell Internet Explorer to load the webpage from "Straits Times", while the fourth line tells the browser to open a new window with the "Channelnewsasia" webpage.

I have left line five for you to add your own website and to demonstrate how you can easily add more websites.

Finally, you have to command the script to finish by telling it to end using the code on line six.

With the script written, it's time to save and test. Select File>Save As, choose a name that you like, save the script as a "Complied Script" to the location user/your user name/ Library/Scripts folder. (You can also save it on the desktop, then select the
Open Scripts folder from ScriptMenu and drop the script into the opened folder.)

Now clicking on the ScriptMenu icon, you should be able to see the name of the script you've just saved. To run it, just select it from there.
Note that the AppleScript commands are all in the AppleScript dictionary of the application you are scripting, such as Microsoft Office, Illustrator, or Photoshop. You can open the AppleScript dictionary by going to File>Open Dictionary.

For further information, check out the Singapore AppleScript Users Group website (homepage. mac.com/ juniortan/applescript/ index.html). Additional resources can be found at the AppleScript website (www. apple.com/AppleScript). You can also refer to books by Ethan Wilde, titled AppleScript for the Internet: Visual QuickStart Guide and AppleScript for Applications: Visual QuickStart Guide.

Fred Teo is from the Mac Users Group of Singapore. Website: www.macuser.org.sg



Copyright © 2000 Singapore Press Holdings. All Rights Reserved