Adobe 65014293 Scripting Guide - Page 9

Scripting Support in Photoshop, JavaScript support

Page 9 highlights

CHAPTER 2: Photoshop Scripting Basics Scripting Support in Photoshop 9 the size of the selected area in an image: "If the selected area is smaller than 2 x 4 inches, add a green border; otherwise add a red border." ➤ A single script can perform actions that involve multiple applications. For example, depending on the scripting language you are using, you could target both Photoshop and another Adobe Creative Suite 4 Application, such as Adobe Illustrator® CS4, in the same script. ➤ You can open, save, and rename files using scripts. ➤ You can copy scripts from one computer to another. If you were using an Action and then switched computers, you'd have to recreate the Action. ➤ Scripts provide more versatility for automatically opening files. When opening a file in an action, you must hard code the file location. In a script, you can use variables for file paths. NOTE: See Photoshop Help for more information on Photoshop Actions. Scripting Support in Photoshop Photoshop supports scripting in three scripting languages: AppleScript, VBScript, and JavaScript. AppleScript and JavaScript run on Mac OS, and JavaScript and VBScript run on Windows. For information about how to choose which scripting language to use, and for additional information about using these languages with Adobe applications, see Introduction to Scripting. See "Creating and running an AppleScript" on page 18, "Creating and running a VBScript" on page 19, and "Creating and running a JavaScript" on page 19. You can call JavaScript scripts from AppleScript and VBScript scripts. See "Executing JavaScripts from AS or VBS" on page 10. For a file to be recognized by Photoshop as a valid script file it must have the correct file name extension: Script type AppleScript JavaScript ExtendScript VBScript Visual Basic File type compiled script OSAS file text text executable JavaScript support Extension .scpt (none) .js .jsx .vbs .exe Platform Mac OS® Mac OS & Windows Windows Windows For a JavaScript file to be recognized by Photoshop as a valid script file, it must use either a .js or a .jsx extension. On the Mac OS, there is no difference in the way scripts with the two extensions function. On Windows, if the script files is opened from inside Photoshop, there is no difference between using the .js and .jsx extension. However, if the script is launched by double-clicking on it, a script with the .js extension is interpreted with the Microsoft® JScript engine, and it cannot launch Photoshop. For Windows, using the .jsx extension is preferable, since it interprets the script with the ExtendScript engine.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87

C
HAPTER
2: Photoshop Scripting Basics
Scripting Support in Photoshop
9
the size of the selected area in an image: “If the selected area is smaller than 2 x 4 inches, add a green
border; otherwise add a red border.”
A single script can perform actions that involve multiple applications. For example, depending on the
scripting language you are using, you could target both Photoshop and another Adobe Creative
Suite 4 Application, such as Adobe Illustrator
®
CS4, in the same script.
You can open, save, and rename files using scripts.
You can copy scripts from one computer to another. If you were using an Action and then switched
computers, you’d have to recreate the Action.
Scripts provide more versatility for automatically opening files. When opening a file in an action, you
must hard code the file location. In a script, you can use variables for file paths.
N
OTE
:
See Photoshop Help for more information on Photoshop Actions.
Scripting Support in Photoshop
Photoshop supports scripting in three scripting languages: AppleScript, VBScript, and JavaScript.
AppleScript and JavaScript run on Mac OS, and JavaScript and VBScript run on Windows. For information
about how to choose which scripting language to use, and for additional information about using these
languages with Adobe applications, see
Introduction to Scripting.
See
“Creating and running an AppleScript” on page 18
,
“Creating and running a VBScript” on page 19
, and
“Creating and running a JavaScript” on page 19
.
You can call JavaScript scripts from AppleScript and VBScript scripts. See
“Executing JavaScripts from AS or
VBS” on page 10
.
For a file to be recognized by Photoshop as a valid script file it must have the correct file name extension:
JavaScript support
For a JavaScript file to be recognized by Photoshop as a valid script file, it must use either a
.js
or a
.jsx
extension. On the Mac OS, there is no difference in the way scripts with the two extensions function. On
Windows, if the script files is opened from inside Photoshop, there is no difference between using the
.js
and
.jsx
extension. However, if the script is launched by double-clicking on it, a script with the
.js
extension is interpreted with the Microsoft
®
JScript engine, and it cannot launch Photoshop. For Windows,
using the
.jsx
extension is preferable, since it interprets the script with the ExtendScript engine.
Script type
File type
Extension
Platform
AppleScript
compiled script
OSAS file
.scpt
(none)
Mac OS®
JavaScript
ExtendScript
text
.js
.jsx
Mac OS & Windows
VBScript
text
.vbs
Windows
Visual Basic
executable
.exe
Windows