Online Book Reader

Home Category

AppleScript_ The Definitive Guide - Matt Neuburg [6]

By Root 1383 0
from personal correspondence from many people, especially Mark Alldritt, Paul Berkowitz, Hamish Sanderson, and the daring duo of William Cook and Warren Harris. Michael Terry performed a truly incisive technical review, and I have been inspired by many of his suggestions. Nancy Kotary once again helped immensely with her clear-eyed copyediting. Finally I wish to thank my editor, Chuck Toporek, and the entire team at O'Reilly Media, for their patience, encouragement, expertise, assistance, adaptability, and industry.

Part I. AppleScript Overview


Part I introduces AppleScript. What is it? How does it work? Where can I use it? What can I do with it? These are the sorts of questions this part answers.

If you already have a notion of what AppleScript is and just want to get on with studying the language, you can skip the first two chapters; but you should read Chapter 3, because it contains fundamental information and definitions that are not repeated later, and on which the rest of the book depends.

The chapters are:

Chapter 1, Why to Use AppleScript

Chapter 2, Where to Use AppleScript

Chapter 3, Basic Concepts

Chapter 1. Why to Use AppleScript


If you've never used AppleScript before, you're probably in need of motivation as much as information. You'd like to know: "What is AppleScript?" You'd also like to know: "And why should I care, anyway?"

Those are good questions, and they are best answered by a brief explanation of what AppleScript is for. Therefore, this first chapter classifies the main uses of AppleScript, along with some examples.

By presenting AppleScript in action, in some typical real-life contexts, I hope to inspire you to imagine how you might use AppleScript in your own life. AppleScript is a big subject, and your best incentive to press ahead is a vision of some task you actually want to accomplish with it. At the same time, you'll have a far easier, more enjoyable experience of AppleScript if your aims are consonant with its nature and abilities.

Tip

In this chapter, the examples are not intended for you to run on your own computer. This is real-life code that works on my machine, but is not expected to run elsewhere. Nor are you expected to understand the code at this point. I'm just showing it to you for purposes of illustration, so glance over it and move on! When you've read more of the book and have learned some AppleScript, you'll understand how to adapt these examples to your own purposes.

The Nature and Purpose of AppleScript


Consider the many and various applications on your computer, and how you typically make them do things. With your hands, you choose menu items, click buttons, and generally wield the mouse and keyboard in the usual way. You also use applications as a source of information; you typically get this information by reading it off the screen, and you can communicate information from one application to another by copying and pasting. Mediating between your hands, your eyes, and the application is your brain: as your eyes get information from the application, your brain decides what to do next, and instructs your hands accordingly.

With AppleScript, you make applications do things programmatically. An AppleScript program has the power to give commands to the application, taking the place of your hands on the mouse and keyboard, and it has the power to ask the application questions, taking the place of your eyes reading the screen; the program itself makes the decisions about what to do next, thus taking the place of your brain. Thus, AppleScript lets you automate the sorts of things you're accustomed to making applications do manually.

Why is that a good thing? For the same reason that any automation is good. AppleScript performs the same tasks you could perform manually, but it performs them faster, more accurately, and without your direct involvement—you needn't even be sitting at the computer. Some tasks, when performed manually, are tedious or repetitive or error-prone; it's downright annoying for you to have to perform them, whereas the computer never

Return Main Page Previous Page Next Page

®Online Book Reader