Adobe 23101764 Scripting Guide - Page 9

JavaScript, 7 Choosing a scripting language

Page 9 highlights

Introduction 1 JavaScript 1.6 JavaScript In addition to writing AppleScripts and Visual Basic scripts, you can also write cross-platform JavaScripts (using the text editor or your choice) on either the Mac or Windows platform. Photoshop provides a built-in, platform-independent framework for executing JavaScripts. The easiest way to run your JavaScripts is to use the "File>Scripts" menu. JavaScripts are stored in or accessed through the Scripts folder. Scripts folder The Scripts folder is located in the "Presets" folder of your Photoshop installation. All JavaScript files placed in the Scripts folder are available for execution from the Scripts menu. On both Mac and Windows, JavaScript files must be saved as text files with a '.js' file name extension. For more information on the JavaScript scripting environment, see Section 3.2.3, "Viewing the JavaScript Environment. 1.7 Choosing a scripting language Your choice of scripting language is determined by two trade-offs: 1. Do you need to run the same script on both Macintosh and Windows computers? 2. Do you need to control multiple applications from the same script? As mentioned earlier, JavaScript is a cross-platform language that works on either platform. The same script will perform identically on Windows and Macintosh computers. However, JavaScript is invoked from the Scripts menu within Photoshop and lacks the facilities to directly address other applications. For example, you cannot easily write a JavaScript to manage workflows involving Photoshop and a database management program. AppleScript and Visual Basic are only offered on their respective platforms. However, you can write scripts in those languages to control multiple applications. For example, you can write an AppleScript that first manipulates a bitmap in Photoshop and then commands a web design application to incorporate it. This same cross-application capability is also available with Visual Basic on Windows. You may also use other scripting languages when working with Photoshop. On Mac OS, any language which lets you send Apple events can be used to script Photoshop. On Windows, any language which is COM aware can be used to script Photoshop. Photoshop CS Scripting Guide 5

  • 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

Photoshop CS Scripting Guide
5
Introduction
JavaScript
1
1.6 JavaScript
In addition to writing AppleScripts and Visual Basic scripts, you can also write cross-platform
JavaScripts (using the text editor or your choice) on either the Mac or Windows platform.
Photoshop provides a built-in, platform-independent framework for executing JavaScripts.
The easiest way to run your JavaScripts is to use the “File>Scripts” menu. JavaScripts are
stored in or accessed through the Scripts folder.
Scripts folder
The Scripts folder is located in the “Presets” folder of your Photoshop installation. All
JavaScript
les placed in the Scripts folder are available for execution from the Scripts menu.
On both Mac and Windows, JavaScript
les must be saved as text
les with a '.js'
le name
extension.
For more information on the JavaScript scripting environment, see
Section 3.2.3, “Viewing the
JavaScript Environment
.
1.7 Choosing a scripting language
Your choice of scripting language is determined by two trade-offs:
1.
Do you need to run the same script on both Macintosh and Windows computers?
2.
Do you need to control multiple applications from the same script?
As mentioned earlier, JavaScript is a cross-platform language that works on either platform.
The same script will perform identically on Windows and Macintosh computers. However,
JavaScript is invoked from the Scripts menu within Photoshop and lacks the facilities to
directly address other applications. For example, you cannot easily write a JavaScript to
manage work
ows involving Photoshop and a database management program.
AppleScript and Visual Basic are only offered on their respective platforms. However, you can
write scripts in those languages to control multiple applications. For example, you can write an
AppleScript that
rst manipulates a bitmap in Photoshop and then commands a web design
application to incorporate it. This same cross-application capability is also available with
Visual Basic on Windows.
You may also use other scripting languages when working with Photoshop. On Mac OS, any
language which lets you send Apple events can be used to script Photoshop.
On Windows, any language which is COM aware can be used to script Photoshop.