Adobe Photoshop CC Scripting Guide
Total Page:16
File Type:pdf, Size:1020Kb
ADOBE PHOTOSHOP CC SCRIPTING GUIDE © 2019 Adobe. All rights reserved. Adobe® Photoshop® CC Scripting Guide Adobe, the Adobe logo, Illustrator, and Photoshop are either registered trademarks or trademarks of Adobe Inc. in the United States and/or other countries. Apple and Mac OS are trademarks of Apple Computer, Inc., registered in the United States and other countries. Microsoft and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and other countries. JavaScript and all Java-related marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. All other trademarks are the property of their respective owners. The information in this document is furnished for informational use only, is subject to change without notice, and should not be construed as a commitment by Adobe Inc. Adobe Inc. assumes no responsibility or liability for any errors or inaccuracies that may appear in this document. The software described in this document is furnished under license and may only be used or copied in accordance with the terms of such license. Adobe Inc., 345 Park Avenue, San Jose, CA 95110-2704 USA, www.adobe.com Contents 1 Introduction . 6 About this Manual . 6 Conventions in this Guide . 6 2 Photoshop Scripting Basics . 8 Scripting Overview . 8 Why use scripts instead of actions? . 8 Scripting Support in Photoshop . 9 JavaScript support . 9 Executing other scripts . 10 Startup scripts . 10 Executing JavaScripts from AS or VBS . 10 Photoshop Object Model . 11 Containment hierarchy . 11 Application and document classes . 12 Layer classes . 12 Layer Comp class . 13 Channel class . 13 Selection class . 13 History State class . 13 Document Info class . 13 Path Item, Sub Path Item, and Path Point classes . 14 Preferences class . 14 Notifier class . 14 Count Item class . 14 Color Sampler class . 14 Measurement Scale class . 14 The containment hierarchy and the Photoshop user interface . 14 Additional objects . 16 Constants . 16 Creating a sample Hello World script . 17 Creating and running an AppleScript . 18 Creating and running a VBScript . 19 Creating and running a JavaScript . 19 3 Scripting Photoshop . 21 Viewing Photoshop Objects, Commands, and Methods . 21 Viewing Photoshop’s AppleScript dictionary . 21 Viewing Photoshop’s type library (VBS) . 22 Targeting and Referencing the Application Object . 22 Creating New Objects in a Script . 23 Setting the Active Object . 25 Setting the active document . 26 3 Contents 4 Setting the active layer . 27 Setting the active channels . 28 Opening a Document . 28 Opening a file with default file format . 28 Specifying file formats to open . 29 Saving a Document . 31 Setting Application Preferences . 32 Allowing or Preventing Dialogs . 33 Working with the Photoshop Object Model . 33 Using the Application object . 34 Using the Document object . 34 Manipulating a document object . 35 Working with layer objects . 36 Creating an ArtLayer object . 37 Creating a Layer Set object . ..