Adobe 23101764 Scripting Guide - Page 66
Executing JavaScripts from AS or VB
UPC - 718659340025
View all Adobe 23101764 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 66 highlights
Scripting Photoshop 3 Executing JavaScripts from AS or VB In Visual Basic and JavaScript ruler units and type units are properties of the Preferences, accessed through the application object's preferences property as shown below. VB: appRef.Preferences.RulerUnits = PsInches appRef.Preferences.TypeUnits = PsTypePixels appRef.Preferences.PointSize = PsPostScriptPoints JS: app.preferences.rulerUnits = Units.INCHES; app.preferences.typeUnits = TypeUnits.PIXELS; app.preferences.pointSize = PointType.POSTSCRIPT; IMPORTANT: Remember to reset the unit settings back to the original values at the end of a script. 3.7 Executing JavaScripts from AS or VB You may want to take advantage of the platform-independence of JavaScript by running scripts from AppleScript or Visual Basic. For AppleScript, use do javascript. For Visual Basic, use either the Application's DoJavaScript or DoJavaScriptFile method. DoJavaScript takes a string, which is the JavaScript code to execute. DoJavaScriptFile opens a file that contains the JavaScript code as illustrated below: AS: set scriptFile to "myscript" as alias do javascript scriptFile VB: Dim appRef As Photoshop.Application Set appRef = CreateObject("Photoshop.Application") appRef.DoJavaScriptFile ("D:\\Scripts\\MosaicTiles.js") Photoshop CS Scripting Guide 62