beginning applescript (programmer to programmer)

601 273 0
beginning applescript (programmer to programmer)

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

TeAM YYeP G Digitally signed by TeAM YYePG DN: cn=TeAM YYePG, c=US, o=TeAM YYePG, ou=TeAM YYePG, email=yyepg@msn.com Reason: I attest to the accuracy and integrity of this document Date: 2005.02.23 05:09:06 +08'00' Beginning AppleScript® Stephen G. Kochan 01_574000 ffirs.qxd 10/29/04 6:20 PM Page i 01_574000 ffirs.qxd 10/29/04 6:20 PM Page ii Beginning AppleScript® Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256-5774 www.wiley.com Copyright © 2005 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 0-7645-7400-0 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 1MA/RX/RR/QU/IN No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, e-mail: brandreview@wiley.com. LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REP- RESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CON- TENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CRE- ATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CON- TAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FUR- THER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFOR- MATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Cataloging-in-Publication Data: Kochan, Stephen G. Beginning Applescript / Stephen Kochan. p. cm. Includes index. ISBN 0-7645-7400-0 (paper/website) 1. AppleScript (Computer program language) I. Title. QA76.73.A67K63 2004 005.13’3 dc22 2004022630 Trademarks: Wiley, the Wiley Publishing logo, Wrox, the Wrox logo, Programmer to Programmer and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. AppleScript is a registered trademark of Apple Computer, Inc. in the U.S. and other countries. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. 01_574000 ffirs.qxd 10/29/04 6:20 PM Page iii 01_574000 ffirs.qxd 10/29/04 6:20 PM Page iv About the Author Stephen G. Kochan has been developing software and writing books for over 20 years. He is the author and coauthor of several best-selling titles on the C language, including Programming in C and Programming in ANSI C (both from Sams Publishing), Programming C for the Mac (Macmillan Computer Publishing), and Topics in C Programming (Wiley Publishing), as well as several Unix titles, including Exploring the Unix System and Unix Shell Programming (both Sams Publishing), and Unix System Security (Hayden Books). His most recent title on Mac programming is Programming in Objective-C (Sams Publishing), which is a tutorial on the primary programming language used on the Mac for application development. 01_574000 ffirs.qxd 10/29/04 6:20 PM Page v 01_574000 ffirs.qxd 10/29/04 6:20 PM Page vi Credits Acquisitions Editor Katie Mohr Senior Development Editor Jodi Jensen Production Editor Pamela Hanley Technical Editor Terrence Talbot Copy Editor Mary Lagu Editorial Manager Mary Beth Wakefield Vice President & Executive Group Publisher Richard Swadley Vice President and Publisher Joseph B. Wikert Project Coordinator April Farling Graphics and Production Specialists Carrie Foster, Denny Hager, Joyce Haughey, Jennifer Heleine Quality Control Technician John Greenough, Carl William Pierce Media Development Specialist Kit Malone Proofreading Sossity R. Smith Indexing TECHBOOKS Production Services 01_574000 ffirs.qxd 10/29/04 6:20 PM Page vii 01_574000 ffirs.qxd 10/29/04 6:20 PM Page viii To my friends Allan, Cesar, Ramon, Lev, and Adrian for always being there 01_574000 ffirs.qxd 10/29/04 6:20 PM Page ix [...]... popularity of AppleScript This was partly due to the fact that more and more applications became scriptable, meaning you could talk to them from an AppleScript program AppleScript was also found to be well suited for automating repetitive tasks in the workplace, a process known as workflow automation Finally, AppleScript s growth in popularity was partly owed to Apple’s recognition and adoption of AppleScript. .. not to say that programmers who intend to use AppleScript for workflow automation should not read this book This book teaches you what you need to know to get started and how to write your scripts However, be forewarned: you will be having some fun along the way! How This Book Is Structured As I just noted, the purpose of this book is to teach you how to write programs in AppleScript It is designed to. .. for workflow automation However, AppleScript is a great language for the hobbyist and computer enthusiast to learn, and those groups are the intended audience for this book Instead of focusing on how to use AppleScript to format data for an Excel Introduction spreadsheet, edit some images in PhotoShop, or create a document with FrameMaker, this book shows how easy it is to use AppleScript to control some... An AppleScript Command to Display a Dialog Understanding the Buttons Parameter in the display dialog Command Try It Out: Using the display dialog’s Buttons Parameter Changing the Labels on a Button Try It Out: Setting the Default Button in a Dialog Adding an Icon to Your Dialog Box Try It Out: Adding a Note Icon to Your Dialog Multiple AppleScript Commands Try It Out: Add a “Beep” Adding Comments to. .. released with the Panther version of Mac OS X (v 10.3) AppleScript Studio, makes the bridge between AppleScript and GUI applications With AppleScript Studio, you can develop a sophisticated user interface and have AppleScript as the underlying code to respond to events like the clicking of a button or the movement of a slider Chapter 14 is an introduction to AppleScript Studio and guides you through the steps... reference to AppleScript s operators and commands Appendix C, “Resources,” contains a list of resources and places you can look for more information about AppleScript and some of the tools mentioned in the text What You Need to Use This Book This book covers the latest version of AppleScript At the time of this writing, the latest version was 1.9.3 You use a separate program to enter and run AppleScript. .. Script Editor Your Mac OS X system comes with some preinstalled tools that you’ll be using in this book One of the most useful ones (as far as AppleScript programming goes) is an application called Script Editor This application allows you to enter, compile, debug, and run your AppleScript programs in an interactive environment It is a simple and effective tool The Script Editor application is stored in... well as many common questions specific to P2P and Wrox books To read the FAQs, click the FAQ link on any P2P page 6 1 Writing Your First AppleScript Program There’s no point in wasting time You are reading this book because you want to learn how to write programs in AppleScript So instead of wading through theory and terminology, I want you to begin by typing an AppleScript program, running it, and looking... The iDVD example shows you how to write an AppleScript program to create a DVD slide show presentation from a folder of images 3 Introduction Chapter 12, “Script Objects,” goes into detail about script objects, showing you how to store them in a file and subsequently load them into your programs You also learn how defining a script object inside a handler allows you to write programs that are consistent... data to it You also learn how to get information about a file, such as its size, its modification date, and its type The chapter shows how to use commands to allow a user to choose a file or a folder on the system and how you can enumerate the contents of a folder in your program A handler is AppleScript s equivalent of a function or subroutine in other languages In Chapter 8, “Handlers,” this topic . vi Credits Acquisitions Editor Katie Mohr Senior Development Editor Jodi Jensen Production Editor Pamela Hanley Technical Editor Terrence Talbot Copy Editor Mary Lagu Editorial Manager Mary Beth. Description to Your Program 14 An AppleScript Command to Display a Dialog 15 Understanding the Buttons Parameter in the display dialog Command 17 Try It Out: Using the display dialog’s Buttons Parameter. the Labels on a Button 19 Try It Out: Setting the Default Button in a Dialog 19 Adding an Icon to Your Dialog Box 20 Try It Out: Adding a Note Icon to Your Dialog 21 Multiple AppleScript Commands

Ngày đăng: 31/05/2014, 23:58

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan