AppleScript: The Definitive Guide, 2/e
暫譯: AppleScript 完全指南(第二版)

Matt Neuburg

  • 出版商: O'Reilly
  • 出版日期: 2006-02-07
  • 定價: $1,300
  • 售價: 6.0$780
  • 語言: 英文
  • 頁數: 592
  • 裝訂: Paperback
  • ISBN: 0596102119
  • ISBN-13: 9780596102111
  • 立即出貨 (庫存 < 4)

買這商品的人也買了...

商品描述

Description

Mac users everywhere--even those who know nothing about programming--are discovering the value of the latest version of AppleScript, Apple's vastly improved scripting language for Mac OS X Tiger. And with this new edition of the top-selling AppleScript: The Definitive Guide, anyone, regardless of your level of experience, can learn to use AppleScript to make your Mac time more efficient and more enjoyable by automating repetitive tasks, customizing applications, and even controlling complex workflows.


Fully revised and updated--and with more and better examples than ever--AppleScript: The Definitive Guide, 2nd Edition explores AppleScript 1.10 from the ground up. You will learn how AppleScript works and how to use it in a variety of contexts: in everyday scripts to process automation, in CGI scripts for developing applications in Cocoa, or in combination with other scripting languages like Perl and Ruby.



AppleScript has shipped with every Mac since System 7 in 1991, and its ease of use and English-friendly dialect are highly appealing to most Mac fans. Novices, developers, and everyone in between who wants to know how, where, and why to use AppleScript will find AppleScript: The Definitive Guide, 2nd Edition to be the most complete source on the subject available. It's as perfect for beginners who want to write their first script as it is for experienced users who need a definitive reference close at hand.



AppleScript: The Definitive Guide, 2nd Edition begins with a relevant and useful AppleScript overview and then gets quickly to the language itself; when you have a good handle on that, you get to see AppleScript in action, and learn how to put it into action for you. An entirely new chapter shows developers how to make your Mac applications scriptable, and how to give them that Mac OS X look and feel with AppleScript Studio. Thorough appendixes deliver additional tools and resources you won't find anywhere else. Reviewed and approved by Apple, this indispensable guide carries the ADC (Apple Developer Connection) logo.

 

Table of Contents

Preface

Part I. AppleScript Overview

1. Why to Use AppleScript

     The Nature and Purpose of AppleScript

     Is This Application Scriptable?

     Calculation and Repetition

     Reduction

     Customization

     Combining Specialties

2. Where to Use AppleScript

     Script Editor

     Internally Scriptable Application

     Script Runner

     Automatic Location

     Application

     Unix

     Hyperlinks

     Automator

3. Basic Concepts

     Apple Events

     The Open Scripting Architecture

     Script

     Compiling and Decompiling

     Compiled Script Files

     Script Text File

     Applet and Droplet

     Scripting Addition

     Dictionary

     Missing External Referents

     Modes of Scriptability

Part II. The AppleScript Language

4. Introducing the Language

     A Little Language

     Extensibility and Its Perils

     The "English-likeness" Monster

     Object-likeness

     LISP-likeness

     The Learning Curve

5. Syntactic Ground of Being

     Lines

     Result

     Comments

     Abbreviations and Synonyms

     Blocks

     The

6. A Map of the World

     Scope Blocks

     Levels and Nesting

     The Top Level

     Code and the Run Handler

     Variables

7. Variables

     Assignment and Retrieval

     Declaration and Definition of Variables

     Variable Names

8. Script Objects

     Script Object Definition

     Run Handler

     Script Properties

     Script Objects as Values

     Top-Level Entities

     Compiled Script Files as Script Objects

     Inheritance

9. Handlers

     Handler Definition

     Returned Value

     Handlers as Values

     Parameters

     Pass by Reference

     Syntax of Defining and Calling a Handler
     Event Handlers

     The Run Handler

     Recursion

     Power Handler Tricks

10. Scope

     Regions of Scope

     Kinds of Variable

     Scope of Top-Level Entities

     Scope of Locals

     Scope of Globals

     Scope of Undeclared Variables

     Declare Your Variables

     Free Variables

     Redeclaration of Variables

     Closures

11. Objects

     Messages

     Attributes

     Class

     Target

     Get

     It

     Me

     Properties and Elements

     Element Specifiers

     Operations on Multiple References

     Assignment of Multiple Attributes

     Object String Specifier

12. References

     Reference as Target

     Reference as Incantation

     Creating a Reference

     Identifying References

     Dereferencing a Reference

     Trouble with Contents

     Creating References to Variables

     Reference as Parameter

13. Datatypes

     Application

     Machine

     Data

     Boolean

     Integer, Real, and Number

     Date

     String

     Unicode Text

     File and Alias

     List

     Record

14. Coercions

     Implicit Coercion

     Explicit Coercion

     Boolean Coercions

     Number, String, and Date Coercions

     File Coercions

     List Coercions

     Unit Conversions

15. Operators

     Implicit Coercion

     Arithmetic Operators

     Boolean Operators

     Comparison Operators

     Containment Operators

     Concatenation Operator

     Parentheses

     Who Performs an Operation

16. Global Properties

     Strings

     Numbers

     Miscellaneous

17. Constants

18. Commands

     Application Commands

     Standard Commands

     Logging Commands

19. Control

     Branching

     Looping

     Tell

     Using Terms From

     With

     Considering/Ignoring

     Errors

     Second-Level Evaluation

Part III. AppleScript In Action

20. Dictionaries

     Resolution of Terminology

     Terminology Clash

     Nonsensical Apple Events

     Raw Four-Letter Codes

     Multiple-Word Terms

     What's in a Dictionary

     The 'aeut' Resource

     Inadequacies of the Dictionary

21. Scripting Additions

     Pros and Cons of Scripting Additions

     Classic Scripting Additions

     Loading Scripting Additions

     Standard Scripting Addition Commands

22. Speed

     Tools of the Trade

     Apple Events

     List Access

     Scripting Additions

     Context

23. Scriptable Applications

     Targeting Scriptable Applications

     Some Scriptable Applications

24. Unscriptable Applications

     Historical Perspective

     Getting Started with Accessibility

     GUI Scripting Examples

25. Unix

     Do Shell Script

     Osascript

26. Triggering Scripts Automatically

     Digital Hub Scripting

     Folder Actions

     CGI Application

     Timers, Hooks, Attachability, Observability

27. Writing Applications

     Applets

     AppleScript Studio

     Cocoa Scripting

     AppleScript Studio Scriptability

Part IV. Appendixes

A. The AppleScript Experience

B. Apple Events Without AppleScript

C. Tools and Resources

Index

商品描述(中文翻譯)

**描述**

Mac 使用者無論身在何處——即使是那些對程式設計一無所知的人——都在發現 AppleScript 最新版本的價值,這是 Apple 為 Mac OS X Tiger 大幅改進的腳本語言。隨著這本暢銷書《AppleScript: The Definitive Guide》的新版本,任何人無論經驗水平如何,都可以學會使用 AppleScript 來提高 Mac 使用效率和樂趣,通過自動化重複任務、自訂應用程式,甚至控制複雜的工作流程。

這本《AppleScript: The Definitive Guide, 2nd Edition》經過全面修訂和更新,並且提供比以往更多更好的範例,從基礎開始探索 AppleScript 1.10。您將學習 AppleScript 的運作方式,以及如何在各種情境中使用它:在日常腳本中進行自動化處理,在 CGI 腳本中開發 Cocoa 應用程式,或與其他腳本語言如 Perl 和 Ruby 結合使用。

自 1991 年 System 7 以來,AppleScript 隨每台 Mac 一同發佈,其易用性和友好的英語方言對大多數 Mac 愛好者具有很大的吸引力。無論是新手、開發者,還是想了解如何、何時及為何使用 AppleScript 的人,都會發現《AppleScript: The Definitive Guide, 2nd Edition》是該主題上最完整的資源。對於想要撰寫第一個腳本的初學者來說,它是完美的;對於需要隨時查閱的經驗豐富的使用者來說,它同樣是不可或缺的參考書。

《AppleScript: The Definitive Guide, 2nd Edition》以相關且有用的 AppleScript 概述開始,然後迅速進入語言本身;當您對此有良好的掌握後,您將看到 AppleScript 的實際應用,並學習如何為您實現它。一個全新的章節向開發者展示如何使您的 Mac 應用程式可腳本化,以及如何使用 AppleScript Studio 賦予它們 Mac OS X 的外觀和感覺。詳細的附錄提供了您在其他地方找不到的額外工具和資源。這本不可或缺的指南經 Apple 審核和批准,並帶有 ADC(Apple Developer Connection)標誌。

**目錄**

前言
**第一部分:AppleScript 概述**
1. 為什麼要使用 AppleScript
- AppleScript 的本質和目的
- 這個應用程式可腳本化嗎?
- 計算和重複
- 簡化
- 自訂
- 結合專業

2. 在哪裡使用 AppleScript
- 腳本編輯器
- 內部可腳本化的應用程式
- 腳本執行器
- 自動位置
- 應用程式
- Unix
- 超連結
- Automator

3. 基本概念
- Apple 事件
- 開放腳本架構
- 腳本
- 編譯和反編譯
- 編譯的腳本檔案
- 腳本文字檔
- Applet 和 Droplet
- 腳本擴充
- 字典
- 缺失的外部參考
- 腳本可用性模式

**第二部分:AppleScript 語言**
4. 語言介紹
- 小語言
- 可擴展性及其風險
- “類英語”怪物
- 物件相似性
- LISP 相似性
- 學習曲線

5. 語法基礎
- 行
- 結果
- 註解
- 縮寫和同義詞
- 區塊

6. 世界地圖
- 範圍區塊
- 層級和嵌套
- 頂層
- 代碼和執行處理器
- 變數

7. 變數
- 指派和檢索
- 變數的宣告和定義
- 變數名稱

8. 腳本物件
- 腳本物件定義
- 執行處理器
- 腳本屬性
- 腳本物件作為值
- 頂層實體
- 編譯的腳本檔案作為腳本物件
- 繼承

9. 處理器
- 處理器定義
- 返回值
- 處理器作為值
- 參數
- 參考傳遞
- 定義和調用處理器的語法
- 事件處理器
- 執行處理器
- 遞歸
- 強大處理器技巧

10. 範圍
- 範圍區域
- 變數類型
- 頂層實體的範圍
- 局部變數的範圍
- 全局變數的範圍
- 未宣告變數的範圍
- 宣告您的變數
- 自由變數
- 變數的重新宣告
- 閉包

11. 物件
- 訊息
- 屬性
- 類別
- 目標
- 獲取
- 它
- 我
- 屬性和元素
- 元素指定符
- 多重參考的操作
- 多重屬性的指派
- 物件字串指定符

12. 參考
- 參考作為目標
- 參考作為咒語
- 創建參考
- 識別參考
- 解除參考
- 內容問題
- 創建對變數的參考
- 參考作為參數

13. 資料類型
- 應用程式
- 機器
- 數據
- 布林值
- 整數、實數和數字
- 日期
- 字串
- Unicode 文本
- 檔案和別名
- 列表
- 記錄

14. 強制轉換
- 隱式強制轉換
- 顯式強制轉換
- 布林強制轉換
- 數字、字串和日期強制轉換
- 檔案強制轉換
- 列表強制轉換
- 單位轉換

15. 運算子
- 隱式強制轉換
- 算術運算子
- 布林運算子
- 比較運算子
- 包含運算子
- 串接運算子
- 括號
- 誰執行操作

16. 全局屬性
- 字串
- 數字
- 其他

17. 常數

18. 命令
- 應用程式命令
- 標準命令
- 日誌命令

19. 控制
- 分支
- 循環
- 告訴
- 使用術語
- 考慮/忽略
- 錯誤
- 第二級評估

**第三部分:AppleScript 實作**
20. 字典
- 術語解析
- 術語衝突
- 無意義的 Apple 事件
- 原始四字碼
- 多字術語
- 字典中的內容
- “aeut”資源
- 字典的不足

21. 腳本擴充
- 腳本擴充的優缺點
- 經典腳本擴充
- 載入腳本擴充
- 標準腳本擴充命令

22. 速度
- 行業工具
- Apple 事件
- 列表訪問
- 腳本擴充
- 上下文

23. 可腳本化的應用程式
- 目標可腳本化的應用程式
- 一些可腳本化的應用程式

24. 不可腳本化的應用程式
- 歷史觀點
- 開始使用可及性
- GUI 腳本範例

25. Unix
- 執行 Shell 腳本
- osascript

26. 自動觸發腳本
- 數位中心腳本
- 資料夾動作
- CGI 應用程式
- 計時器、鉤子、可附加性、可觀察性

27. 撰寫應用程式
- Applet
- AppleScript Studio
- Cocoa 腳本
- AppleScript Studio 腳本能力

**附錄**
A. AppleScript 體驗
B. 無需 AppleScript 的 Apple 事件