Adobe 23101335 Scripting Guide - Page 50

Executing one-line JavaScripts, 3.7 The Application object

Page 50 highlights

Scripting Photoshop 3 The Application object ● never (NeverShowDebugger): This option will disable debugging from the JavaScript. Any error that occurs in the JavaScript will result in a JavaScript exception being thrown. Note that you can catch JavaScript exceptions in your script; see 2.10.3, "JavaScript Debugging" on page 26 for more information on how to handle JavaScript exceptions. When you use this option the JavaScript command "debugger();" will be ignored. ● on runtime error (DebuggerOnError): This option will automatically stop the execution of your JavaScript when a runtime error occurs and show the JavaScript debugger. When you use this option the JavaScript command "debugger();" will stop the JavaScript and display the JavaScript debugger. ● before running (BeforeRunning): This option will show the JavaScript debugger at the beginning of your JavaScript. When you use this option the JavaScript command "debugger();" will stop the JavaScript and display the JavaScript debugger. 3.6.2 Executing one-line JavaScripts You can also execute simple JavaScripts directly without passing a file as shown in the following examples. AS: do javascript "alert('alert text');" VB: objApp.DoJavaScript ("alert('alert text');") 3.7 The Application object AppleScript and Visual Basic scripts can target multiple applications so the first thing you should do in your script is target Photoshop. By using the properties and commands of the Application object, you can work with global Photoshop settings, open documents, execute actions, and exercise other Photoshop functionality. Targeting the Application object To target the Photoshop application in AppleScript, you must use a tell..end tell block. By enclosing your Photoshop commands in the following statement, AppleScript will understand you are targeting Photoshop. tell application "Adobe Photoshop 7.0" ... end tell Photoshop 7.0 Scripting Guide 50

  • 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

Photoshop 7.0 Scripting Guide
50
Scripting Photoshop
The Application object
3
never (NeverShowDebugger)
: This option will disable debugging from the JavaScript.
Any error that occurs in the JavaScript will result in a JavaScript exception being thrown.
Note that you can catch JavaScript exceptions in your script; see
2.10.3, “JavaScript
Debugging” on page 26
for more information on how to handle JavaScript exceptions.
When you use this option the JavaScript command “debugger();” will be ignored.
on runtime error (DebuggerOnError)
: This option will automatically stop the
execution of your JavaScript when a runtime error occurs and show the JavaScript
debugger. When you use this option the JavaScript command “debugger();” will stop the
JavaScript and display the JavaScript debugger.
before running (BeforeRunning)
: This option will show the JavaScript debugger at
the beginning of your JavaScript. When you use this option the JavaScript command
“debugger();” will stop the JavaScript and display the JavaScript debugger.
3.6.2 Executing one-line JavaScripts
You can also execute simple JavaScripts directly without passing a file as shown in the
following examples.
AS:
do javascript "alert('alert text');"
VB:
objApp.DoJavaScript ("alert('alert text');")
3.7 The Application object
AppleScript and Visual Basic scripts can target multiple applications so the first thing you
should do in your script is target Photoshop.
By using the properties and commands of the Application object, you can work with global
Photoshop settings, open documents, execute actions, and exercise other Photoshop
functionality.
Targeting the Application object
To target the Photoshop application in AppleScript, you must use a
tell..end tell
block.
By enclosing your Photoshop commands in the following statement, AppleScript will
understand you are targeting Photoshop.
tell application "Adobe Photoshop 7.0"
end tell