Danh mục

Getting Started with AppleScript

Số trang: 10      Loại file: pdf      Dung lượng: 43.95 KB      Lượt xem: 19      Lượt tải: 0    
Hoai.2512

Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

7.5. Getting Started with AppleScript AppleScript is a powerful computer language thats been around since the days of Mac OS 7.
Nội dung trích xuất từ tài liệu:
Getting Started with AppleScript7.5. Getting Started with AppleScriptAppleScript is a powerful computer language thats been around since the days of MacOS 7. Despite its maturity, however, AppleScript is often criticized by seasoned Macprogrammers for being too simple, too easy to learn, and too much like English.Of course, those are precisely the traits you want in a computer language—assuming, ofcourse, that you want to use a computer language at all. If youre an everyday Mac fan—as opposed to some computer-science Ph.D.—AppleScript is by far the easiestprogramming language to use for automating your Mac.You can think of AppleScript programs (called scripts) as software robots. A simpleAppleScript might perform some daily task, like backing up your Documents folder. Amore complex script can be pages long. In professional printing and publishing, whereAppleScript has an army of hard-core fans, a script might connect to a photographershard drive elsewhere on the Internet, download a photo from a predetermined folder,color-correct it in Photoshop, import it into a specified page-layout document, print aproof copy, and send a notification email to the editor—automatically.Even if youre not aware of it, you use the technology that underlies AppleScript all thetime. Behind the scenes, numerous components of your Mac communicate with eachother by sending Apple Events, which are messages bearing instructions or data that yourprograms send to each other. When you use the Show Original command for an alias, orthe Get Info command for a file or folder, an Apple Event tells the Finder how torespond.AppleScript has several important advantages over Automator—not least of which is itseven greater power. Still, AppleScript is a very deep subject—so deep, in fact, that youdneed an entire book to do it justice. This chapter is an appetizer; a book like AppleScript:The Missing Manual is the seven-course meal.Tip: You can also download an entire chapter about AppleScript—the chapter thatappeared in the previous edition of this book—from this books Missing CD page atwww.missingmanuals.com.7.5.1. The Script MenuYou dont have to create AppleScripts to get mileage out of this technology. Mac OS Xcomes with several dozen prewritten scripts that are genuinely useful—and all you haveto do is choose their names from a menu. Playing back an AppleScript in this wayrequires about as much technical skill as pressing an elevator button.To sample some of these cool starter scripts, you should first add the Script menu to yourmenu bar (see Figure 7-16, right). Figure 7-16. Left: Leopards starter scripts appear in categories. Right: To make the Script Menu appear, open Applications AppleScript Apple-Script Utility; turn on Show Script Menu in menu bar. Apple-Script Utility puts all of the AppleScript options in one place.The Script Menu provides 16 premade categories, which incorporate over 100 scripts;just choose a scripts name to make it run. Heres a summary of the most useful and funscripts.Tip: If you press the Shift key as you choose a scripts name from the Script menu, MacOS X takes you directly to that scripts location in the Finder (for example, your Home Library Scripts folder). Better yet, if you press Option as you choose its name,you open the script in Script Editor for inspection or editing.7.5.1.1. Address Book ScriptsIn this submenu, youll find Import Addresses, which is designed to move your namesand addresses into Mac OS Xs Address Book program from Entourage, OutlookExpress, Palm Desktop, Eudora, Claris Emailer, or Netscape. If youve got a lot offriends, use this script; youll be glad that you wont have to re-enter all their names,phone numbers, and email addresses. (The accompanying Address Importers sub-folderoffers scripts to import from three specific programs.)7.5.1.2. BasicsThis submenu offers three small, handy scripts related to AppleScript: AppleScript Help(which opens the Help Viewer and searches for the word AppleScript); Apple-Script Website (which opens the AppleScript Web page in your Web browser); and Open ScriptEditor (opens the Script Editor program, the program you use to read and writeAppleScripts).7.5.1.3. ColorSyncIn this folder, youll find a bunch of ColorSync script droplets (scripts that run when youdrop something on their icons) primarily designed for graphic artists, Web site designers,publishers, and so on.In some cases, choosing a scripts name from the menu produces a terse help message,and then an Open dialog box for choosing the graphics file you want to process.Others have an immediate effect. The Mimic PC monitor script, for example, adjuststhe colors of your screen so they closely resemble the slightly different hues of aWindows PC monitor. Thats a blessing if youre working on a photo or Web page, ...

Tài liệu được xem nhiều: