Adobe 23101764 Scripting Guide - Page 18

Hello World Sample Scripts

Page 18 highlights

Scripting basics 2 Object Model 2.3.2 Hello World Sample Scripts When all is said and done, the Object Model is simply a means to an end -- writing Photoshop scripts that accomplish something useful using the classes provided. Traditionally, the first thing to accomplish in any programming environment is the display of a "Hello World" message. You can script such a message in Photoshop CS using AppleScript, Visual Basic or JavaScript. Regardless of the language employed, the basic steps involved are the same: • Open the Photoshop application • Create a new document object • Add an art layer to the document • Change the art layer to a text item • Set the contents of the text item These steps mirror a specific path in the containment hierarchy, as illustrated below. Application Document Art Layer Text Item The relationships exposed in the containment hierarchy are fully preserved in the scripting sequence. Understanding the Object Model is the key to writing effective scripts in Photoshop CS. To see how this plays out in practice, we include three sample scripts implementing "Hello World!". NOTE: For details on advanced scripting techniques for AppleScript, Visual Basic and JavaScript, see Chapter 3, "Scripting Photoshop. Photoshop CS Scripting Guide 14

  • 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
14
Scripting basics
Object Model
2
2.3.2
Hello World Sample Scripts
When all is said and done, the Object Model is simply a means to an end -- writing Photoshop
scripts that accomplish something useful using the classes provided. Traditionally, the
rst
thing to accomplish in any programming environment is the display of a "Hello World"
message.
You can script such a message in Photoshop CS using AppleScript, Visual Basic or JavaScript.
Regardless of the language employed, the basic steps involved are the same:
Open the Photoshop application
Create a new document object
Add an art layer to the document
Change the art layer to a text item
Set the contents of the text item
These steps mirror a speci
c path in the containment hierarchy, as illustrated below.
The relationships exposed in the containment hierarchy are fully preserved in the scripting
sequence. Understanding the Object Model is the key to writing effective scripts in
Photoshop CS.
To see how this plays out in practice, we include three sample scripts implementing "Hello
World!".
N
OTE
:
For details on advanced scripting techniques for AppleScript, Visual Basic and
JavaScript, see
Chapter 3, “Scripting Photoshop
.
Application
Document
Art Layer
Text Item