AppleScript
Mark Conway Munro
AppleScript
Published byWiley Publishing, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.wiley.com
Copyright 2010 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-56229-1
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
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 Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, 201-748-6011, fax 201-748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained 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 further information does not mean that the author or the publisher endorses the information 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 (877) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002.
Library of Congress Control Number: 2010925705
Trademarks: Wiley and the Wiley logo 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, Inc. 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. AppleScript Developer Reference is an independent publication and has not been authorized, sponsored, or otherwise approved by Apple, Inc.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
Credits
Acquisitions Editor
Aaron Black
Executive Editor
Jody Lefevere
Project Editor
Katharine Dvorak
Technical Editor
Rob Vanderwerf
Copy Editor
Lauren Kennedy
Editorial Director
Robyn Siesky
Business Manager
Amy Knies
Senior Marketing Manager
Sandy Smith
Vice President and Executive Group Publisher
Richard Swadley
Vice President and Executive Publisher
Barry Pruett
Project Coordinator
Lynsey Stanford
Graphics and Production Specialists
Andrea HornbergerErin Zeltner
Quality Control Technician
John Greenough
Proofreading
C. M. Jones
Indexing
WordCo Indexing Services
Media Development Project Manager
Laura Moss
Media Development Assistant Project Manager
Jenny Swisher
Media Development Associate Producer
Doug Kuhn
About the Author
Mark Conway Munro is an entrepreneur who turned a software-writing hobby into a business. Mark was born in Indiana and raised in Ohio. In 1986, Mark moved to New York City. As the manager of Louis Tannen's Magic Store in New York City, he taught himself the Macintosh Computer and FileMaker Pro while building a database of inventory, which eventually led to the development of a networked order processing solution. From there he went on to work for the Jack Morton Company, where he was the Network and Telecommunications Manager. He began developing custom solutions with HyperCard and FileMaker Pro in his spare time. After the release of AppleScript in 1992, he refocused his experience with computer networking, training, technical support, database development, and custom application development. He quickly transitioned from HyperTalk to AppleScript and began building custom workflow automation solutions.
Mark founded Write Track Media in 1994, where he continues to develop innovative solutions that eliminate repetition and optimize computerized workflows. Write Track Media has since become known for its reputation for excellence, and has developed complex automated solutions for companies in a variety of industries all across the country including Adobe Systems, The Associated Press, BMG, Dreyfus, Entertainment Weekly, Epson, KraftMaid, McCann-Erickson, The Miami Herald, MYOB, Nabisco, NASA, Nikon, Random House, Reader's Digest, Sony Music Entertainment, and many other companies.
Currently Mark resides in Pennsylvania, where Write Track Media is located. In his spare time, he enjoys hiking and nature photography.
Dedication
To my father, Philip Conway Munro, for teaching me the difference between hardware and software at an early age.
Foreword
T welve years ago Mark Munro asked me to write something for the Web site he was building for his company, Write Track Media. I had already been working with him for about three years: me as an editor and in-house FileMaker developer at the country's second-largest record company, and Mark as outside FileMaker and AppleScript developer. He had helped build the departmental Mac-based database of discs, tapes, and videos with up-to-date listings of all their artists, prices, genres, formats, and so on. But the major part of the project, and where Mark was proving so invaluable, was in the system's output.
We needed to produce a monthly pocket-sized catalog of the active product about 13,000 data records. Mark automated production so that I could generate a 180-page complexly styled catalog using FileMaker Pro, AppleScript, and Quark at the push of a button. We needed to constantly produce multipage order forms with elaborate line listings and scannable barcodes. Mark automated these so that one button would trigger the form to build from scratch: Quark firing up, new blank documents opening, text boxes being created and placed, text flying into the boxes, picture boxes being created, AppleScript running off and building barcode images for each product, bringing them back, dropping them into the picture boxes, sizing them to fit. All this looked like magic to the IT guys that would drop by occasionally, none of them Mac users, with no idea that an application like AppleScript existed that could make the programs all talk to each other. It was magic to us, too: the documents were data driven, accuracy was better than it ever had been, and the automation was saving countless hours of typing, page layout, and proofreading every week.