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
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, ...
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ìm kiếm theo từ khóa liên quan:
công nghệ thông tin kỹ thuật lập trình hệ điều hành đồ họa thiết kế OReilly Mac.OS.X Leopard The Missing Manual Getting Started with AppleScriptGợi ý tài liệu liên quan:
-
Giáo trình Lý thuyết hệ điều hành: Phần 1 - Nguyễn Kim Tuấn
110 trang 435 0 0 -
52 trang 410 1 0
-
Top 10 mẹo 'đơn giản nhưng hữu ích' trong nhiếp ảnh
11 trang 291 0 0 -
Báo cáo thực tập thực tế: Nghiên cứu và xây dựng website bằng Wordpress
24 trang 286 0 0 -
74 trang 275 0 0
-
96 trang 275 0 0
-
Tài liệu dạy học môn Tin học trong chương trình đào tạo trình độ cao đẳng
348 trang 265 1 0 -
Đồ án tốt nghiệp: Xây dựng ứng dụng di động android quản lý khách hàng cắt tóc
81 trang 261 0 0 -
Giáo trình Nguyên lý các hệ điều hành: Phần 2
88 trang 256 0 0 -
175 trang 253 0 0