Adobe 27510753 Scripting Guide - Page 82

Namespace specifiers, Script locations and checking application installation - illustrator

Page 82 highlights

74 Using ExtendScript Tools and Features Adobe InDesign CS2 Scripting Guide Namespace specifiers When calling cross-DOM and exported functions from other applications, a namespace specifier qualifies the function call, directing it to the appropriate application.Namespace specifiers consist of an application name, as used in an application specifier, with an optional major version number. Use it as a prefix to an exported function name, with the JavaScript dot notation. appname[majorVersion].functionName(args) For example: l To call the cross-DOM function quit in Photoshop CS2, use photoshop.quit(), and to call it in GoLive CS2, use golive.quit(). l To call the exported function place, defined for Illustrator® CS version 12, call illustrator12. place(myFiles). For information about the cross-DOM and exported functions, see the Bridge JavaScript Reference, available with Adobe Creative Suite 2. Script locations and checking application installation On startup, all Adobe Creative Suite 2 applications execute all JSX files that they find in the user startup folder: l In Windows, the startup folder is: %APPDATA%\Adobe\StartupScripts l In Mac OS, the startup folder is ~/Library/Application Support/Adobe/StartupScripts/ A script in the startup directory is executed on startup by all applications. If you place a script here, it must contain code to check whether it is being run by the intended application. You can do this using the appName static property of the BridgeTalk class. For example: if( BridgeTalk.appName == "bridge" ) { //continue executing script } In addition, each application looks for application-specific scripts in a subfolder named with that application's specifier and version, in the form: %APPDATA%\Adobe\StartupScripts\appname\version ~/Library/Application Support/Adobe/StartupScripts/appname/version/ The name and version in these folder names are specified in the form required for Application specifiers. For example, in Windows, GoLive CS2 version 8.2 would look for scripts in the directory: %APPDATA%\Adobe\StartupScripts\golive\8.2 The version portion of the Bridge-specific folder path is an exact version number. That is, scripts in the folder bridge/1.5 are executed only by Bridge version 1.5, and so on. If a script that is run by one application will communicate with another application, or add functionality that depends on another application, it must first check whether that application and version is installed. You can do this using the BridgeTalk.getSpecifier static function. For example: if( BridgeTalk.appName == "bridge" ) { // Check that PS CS2 is installed if( BridgeTalk.getSpecifier("photoshop",9)){ // add PS automate menu to Bridge UI } } For interapplication communication details, see the Bridge JavaScript Reference, available with Creative Suite 2.

  • 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
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184

74
Using ExtendScript Tools and Features
Adobe InDesign CS2 Scripting Guide
Namespace specifiers
When calling cross-DOM and exported functions from other applications, a namespace specifier qualifies the
function call, directing it to the appropriate application.Namespace specifiers consist of an application name,
as used in an application specifier, with an optional major version number. Use it as a prefix to an exported
function name, with the JavaScript dot notation.
appname
[
majorVersion
].
functionName
(
args
)
For example:
To call the cross-DOM function
quit
in Photoshop CS2, use
photoshop.quit()
, and to call it in GoLive
CS2, use
golive.quit()
.
To call the exported function
place
, defined for Illustrator® CS version 12, call
illustrator12.
place(myFiles)
.
For information about the cross-DOM and exported functions, see the
Bridge JavaScript Reference
, available
with Adobe Creative Suite 2.
Script locations and checking application installation
On startup, all Adobe Creative Suite 2 applications execute all JSX files that they find in the user startup folder:
In Windows, the startup folder is:
%APPDATA%\Adobe\StartupScripts
In Mac OS, the startup folder is
~/Library/Application Support/Adobe/StartupScripts/
A script in the startup directory is executed on startup by all applications. If you place a script here, it must
contain code to check whether it is being run by the intended application. You can do this using the
appName
static property of the
BridgeTalk
class. For example:
if( BridgeTalk.appName == "bridge" ) {
//continue executing script
}
In addition, each application looks for application-specific scripts in a subfolder named with that application’s
specifier and version, in the form:
%APPDATA%\Adobe\StartupScripts\
appname
\
version
~/Library/Application Support/Adobe/StartupScripts/
appname
/
version
/
The name and version in these folder names are specified in the form required for Application specifiers. For
example, in Windows, GoLive CS2 version 8.2 would look for scripts in the directory:
%APPDATA%\Adobe\StartupScripts\golive\8.2
The
version
portion of the Bridge-specific folder path is an exact version number. That is, scripts in the folder
bridge/1.5
are executed only by Bridge version 1.5, and so on.
If a script that is run by one application will communicate with another application, or add functionality that
depends on another application, it must first check whether that application and version is installed. You can
do this using the
BridgeTalk.getSpecifier
static function. For example:
if( BridgeTalk.appName == "bridge" ) {
// Check that PS CS2 is installed
if(
BridgeTalk.getSpecifier("photoshop",9)
){
// add PS automate menu to Bridge UI
}
}
For interapplication communication details, see the
Bridge JavaScript Reference
, available with Creative Suite 2.
l
l
l
l