Adobe 65015634 Scripting Guide - Page 62
Photoshop > Preferences > Units & Rulers, In Photoshop, choose
UPC - 883919159232
View all Adobe 65015634 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 62 highlights
CHAPTER 3: Scripting Photoshop Advanced Scripting 62 VBS --check to see whether any documents are open --if none are found, create a document --use the default document settings as its properties if (count of documents) is 0 then make new document with properties ¬ {width:theDocWidthInInches, height:theDocHeightInInches,¬ resolution:theDocResolution, name:theDocString} end if --change the settings back to the original units stored in the variables set ruler units of settings to theStartRulerUnits set type units of settings to theStartTypeUnits set display dialogs to theStartDisplayDialogs end tell 2. In Photoshop, choose Photoshop > Preferences > Units & Rulers to verify that your preferences have been returned to your original settings. 3. After viewing the document in Photoshop, close the document without saving it. 4. Save the script as HelloWorldDoc. To work with document preferences: 1. Create the following script. See "Creating and running a VBScript" on page 19 for details. 'create variables for default preferences, new preferences Dim startRulerUnits Dim startTypeUnits Dim docWidthInInches Dim docHeightInInches Dim resolution Dim helloWorldStr Dim appRef Set appRef = CreateObject("Photoshop.Application") 'assign default preferences to save values in variables startRulerUnits = appRef.Preferences.RulerUnits startTypeUnits = appRef.Preferences.TypeUnits startDisplayDialogs = appRef.DisplayDialogs 'set new preferences and document defaults appRef.Preferences.RulerUnits = 2 'for PsUnits --> 2 (psInches) appRef.Preferences.TypeUnits = 1 'for PsTypeUnits --> 1 (psPixels) appRef.DisplayDialogs = 3 'for PsDialogModes --> 3 (psDisplayNoDialogs) docWidthInInches = 4 docHeightInInches = 2 resolution = 72 helloWorldStr = "Hello, World!" 'see if any documents are open 'if none, create one using document defaults If appRef.Documents.Count = 0 Then appRef.Documents.Add docWidthInInches, docHeightInInches, resolution, helloWorldStr End If