Adobe 65014293 Scripting Guide - Page 10

Executing other scripts, Startup scripts, Executing JavaScripts from AS or VBS - photoshop

Page 10 highlights

CHAPTER 2: Photoshop Scripting Basics Scripting Support in Photoshop 10 Scripts written in JavaScript can be accessed from the Adobe Photoshop Scripts menu (File > Scripts), which provides quick and easy access to your JavaScripts. By putting a JavaScript file into the appropriate location on disk, it can be accessed directly from the Photoshop menu. To install a JavaScript in the Scripts menu, place it in the Scripts folder (Photoshop CS4 /Presets /Scripts). The names of the scripts in the Scripts folder, without the file name extension, are displayed in the Scripts menu. Any number of scripts may be installed in the Scripts menu. Scripts added to the Scripts folder while Photoshop is running do not appear in the Scripts menu until the next time you launch the application. All scripts found in the Scripts folder and sub-folders are displayed at the top level of the File > Scripts menu. The addition of sub-folders does not add a hierarchical organization to the Scripts menu. Executing other scripts The Browse item at the end of the Scripts menu (File > Scripts > Browse) allows you to execute scripts that are not installed in the Scripts folder. You can also use Browse to select scripts installed in the Scripts folder after the application was last launched. Selecting Browse displays a file browser dialog which allows you to select a script file for execution. Only .js or .jsx files are displayed in the browse dialog. When you select a script file, it is executed the same way as an installed script. Startup scripts On startup, Photoshop executes all .jsx files that it finds in the startup folders. ➤ On Windows, the startup folder for user-defined scripts is: C:\Program Files\Common Files\Adobe\Startup Scripts CS4\Adobe Photoshop ➤ On Mac OS, the startup folder for user-defined scripts is: ~/Library/Application Support/Adobe/Startup Scripts CS4/Adobe Photoshop If your script is in this main startup folder, it is also executed by all other Adobe Creative Suite 3 applications at startup. If such a script is meant to be executed only by Photoshop, it must include code such as the following: if( BridgeTalk.appName == "photoshop" ) { //continue executing script } For additional details, see the JavaScript Tools Guide. Executing JavaScripts from AS or VBS You can take advantage of JavaScript's platform-independence by running scripts from AppleScript or VBScript. You can execute either a single JavaScript statement or a complete JavaScript file. For more information, please refer to Introduction to Scripting.

  • 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
10
Scripts written in JavaScript can be accessed from the Adobe Photoshop Scripts menu (
File > Scripts
),
which provides quick and easy access to your JavaScripts. By putting a JavaScript file into the appropriate
location on disk, it can be accessed directly from the Photoshop menu.
To install a JavaScript in the Scripts menu, place it in the Scripts folder (
Photoshop CS4 /Presets /Scripts
).
The names of the scripts in the Scripts folder, without the file name extension, are displayed in the Scripts
menu. Any number of scripts may be installed in the Scripts menu.
Scripts added to the Scripts folder while Photoshop is running do not appear in the Scripts menu until the
next time you launch the application.
All scripts found in the Scripts folder and sub-folders are displayed at the top level of the
File > Scripts
menu. The addition of sub-folders does not add a hierarchical organization to the Scripts menu.
Executing other scripts
The
Browse
item at the end of the
Scripts
menu (
File > Scripts > Browse
) allows you to execute scripts
that are not installed in the Scripts folder. You can also use Browse to select scripts installed in the Scripts
folder after the application was last launched.
Selecting
Browse
displays a file browser dialog which allows you to select a script file for execution. Only
.js
or
.jsx
files are displayed in the browse dialog. When you select a script file, it is executed the same
way as an installed script.
Startup scripts
On startup, Photoshop executes all
.jsx
files that it finds in the startup folders.
On Windows, the startup folder for user-defined scripts is:
C:\Program Files\Common Files\Adobe\Startup Scripts CS4\Adobe Photoshop
On Mac OS, the startup folder for user-defined scripts is:
~/Library/Application Support/Adobe/Startup Scripts CS4/Adobe Photoshop
If your script is in this main startup folder, it is also executed by all other Adobe Creative Suite 3
applications at startup. If such a script is meant to be executed only by Photoshop, it must include code
such as the following:
if( BridgeTalk.appName == "photoshop" ) {
//continue executing script
}
For additional details, see the
JavaScript Tools Guide
.
Executing JavaScripts from AS or VBS
You can take advantage of JavaScript’s platform-independence by running scripts from AppleScript or
VBScript. You can execute either a single JavaScript statement or a complete JavaScript file. For more
information, please refer to
Introduction to Scripting
.