Adobe 65048599 Scripting Guide - Page 61
Working with document preferences, Creating and running an AppleScript
View all Adobe 65048599 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 61 highlights
CHAPTER 3: Scripting Photoshop Advanced Scripting 61 Working with document preferences The sample scripts in this section activate a Photoshop Application object and then save the default configuration settings into variables so that they can be restored later when the script completes. These are the default configurations you probably set up in the Preferences dialog when you initially installed and configured Photoshop. NOTE: To view or set the Preferences on Mac OS, choose Photoshop > Preferences > Units & Rulers; in Windows choose Edit > Preferences > Units & Rulers. Next, the scripts set the following preferences to the following values: Preference Set to What it does rulers inches Uses inches as the unit of measurement for graphics. units pixels Uses pixels as the unit of measurement for text (type). dialog modes never Suppresses the use of dialogs so that your script executes without the user being asked for input (such as clicking an OK button) at various stages of the process. NOTE: dialog modes is not an option in the Photoshop application. Next, the script declares variables that store document dimensions in inches and document resolution in pixels. The script then declares a display resolution, and assigns the text "Hello, World!" to a string variable. Next, an if statement checks whether a Document object has been created and then creates a new Document object if none exists. Finally, the script restores the original preferences. AS To work with document preferences: 1. Create and run the following script. See "Creating and running an AppleScript" on page 18 for details. tell application "Adobe Photoshop CS5" --make Photoshop CS5 the active (front-most) application activate --create variables for the default settings set theStartRulerUnits to ruler units of settings set theStartTypeUnits to type units of settings set theStartDisplayDialogs to display dialogs --change the settings set ruler units of settings to inch units set type units of settings to pixel units set display dialogs to never --create variables for default document settings set theDocWidthInInches to 4 set theDocHeightInInches to 2 set theDocResolution to 72 set theDocString to "Hello, World!"