AppleScript Basics |
|||
|
ISBN : |
Order a printed copy of this book from Amazon. --UNAVAILABLE-- |
||
![]() Cover Design - AppleScript Basics |
For your free electronic copy of this book please verify the numbers below. (We need to do this to make sure you're a person and not a malicious script) | ||
|
Sample Chapter From AppleScript Basics Copyright © Jerry Stratton |
|||
Why AppleScript?AppleScript can automate monotonous, repetitive tasks, or tasks that need to be performed at a specific time. Mac OS X can (using its built-in scheduler via programs such as Cronnix) run any script on the minute you need it to run. AppleScript makes it easy to talk to standard Macintosh applications. It can glue applications together so that each application does what it does best. AppleScript is amazingly easy to understand even in English: Tell application Netscape Communicator to OpenURL www.CNN.com This is a valid AppleScript statement. If you use it, Netscape will open the CNN web site. Script EditorEvery Macintosh comes with a program called Script Editor that allows you to create AppleScripts. It lets you write them yourself, or it lets you record your actions. On Mac OS 9, the Script Editor is in your Applications folder, inside of Apple Extras and then AppleScript. In Mac OS X, the Script Editor is in the Applications folder, inside of the Utilities folder. Recording ActionsAny action that is scriptable will be recorded and placed into Script Editor automatically. Recording actions allows you to quickly build up a basic AppleScript. For example, if you go into Script Editor and hit the Record button before visiting a web page, you might end up with something like: tell application "Netscape Communicator™" activate GetURL "www.godsmonsters.com" inside window 1 end tell This tells the program (application) called Netscape Communicator to first active, and then get the URL (GetURL) called www.godsmonsters.com. Place it into window 1. Open Four News SitesLets say that you want to always start up your computer with a web browser for four news sites, each in its own window, arranged on your screen. Go into Script Editor and get rid of whatever is currently there. Click Record and then go into Netscape Communicator. Open a new window for each of: o www.cnn.com o news.google.com o news.yahoo.com o cerebus.sandiego.edu/~jerry/blog/ Once youve arranged the windows how you like them, save your script. Call it Open News and save it as format Application. Quit Netscape and double-click your Open News AppleScript. It will open the windows mostly as you set it. There may be some issues--some of your steps were scriptable and others werent. Recording steps is often the best way to begin creating an AppleScript.
|
|||