Adobe 23101764 Scripting Guide - Page 69

appRef.ActiveDocument = appRef.DocumentsMy Document

Page 69 highlights

Scripting Photoshop 3 The Application object AS: set docRef to current document VB: Set docRef = appRef.ActiveDocument JS: docRef = app.activeDocument; You can also switch back and forth between documents by setting the active document. AS: set current document to document "My Document" VB: appRef.ActiveDocument = appRef.Documents("My Document") JS: app.activeDocument = app.documents["My Document"]; Application preferences The application object contains a property for Photoshop preferences. The preferences property is itself an object and has many properties. The name of the preferences object for the three languages is the following: AS: settings VB: Preferences JS: preferences The properties in the preferences object correlate to the preferences found by displaying the Photoshop "Preferences" dialog in the user interface (select the "Edit > Preferences" menu in Photoshop). Display dialogs It is important to be able to control dialogs properly from a script. If a dialog is shown your script stops until a user dismisses the dialog. This is normally fine in an interactive script that expects a user to be sitting at the machine. But if you have a script that runs in an unsupervised (batch) mode you do not want dialogs to be displayed and stop your script. Using the display dialogs (DisplayDialogs/displayDialogs) property on the application object you can control whether or not dialogs are displayed. If you set display dialogs to always ( psDisplayAllDialogs/ALL ), Photoshop will show all user related dialogs. This is typically not what you want. If you set display dialogs to error dialogs (DisplayErrorDialogs/ERROR), then only dialogs related to errors are shown. You would typically use this setting when you are developing a script or if your script is an interactive one that expects a user to be sitting at the machine while running the script. If you set display dialogs to never ( DisplayNoDialogs/NO ), then no dialogs are shown. If an error occurs it will be returned as an error to the script. See section 2.10.4, "Error handling" on page 29 for more information on catching errors. Photoshop CS Scripting Guide 65

  • 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
65
Scripting Photoshop
The Application object
3
AS:
set docRef to current document
VB:
Set docRef = appRef.ActiveDocument
JS:
d
ocRef = app.activeDocument;
You can also switch back and forth between documents by setting the active document.
AS:
set current document to document "My Document"
VB:
appRef.ActiveDocument = appRef.Documents("My Document")
JS:
app.activeDocument = app.documents["My Document"];
Application preferences
The application object contains a property for Photoshop preferences. The preferences
property is itself an object and has many properties. The name of the preferences object for the
three languages is the following:
AS:
settings
VB:
Preferences
JS:
preferences
The properties in the preferences object correlate to the preferences found by displaying the
Photoshop “Preferences” dialog in the user interface (select the “Edit > Preferences” menu in
Photoshop).
Display dialogs
It is important to be able to control dialogs properly from a script. If a dialog is shown your
script stops until a user dismisses the dialog. This is normally
ne in an interactive script that
expects a user to be sitting at the machine. But if you have a script that runs in an unsupervised
(batch) mode you do not want dialogs to be displayed and stop your script.
Using the
display dialogs
(
DisplayDialogs/displayDialogs
) property on the
application object you can control whether or not dialogs are displayed.
If you set
display dialogs
to
always ( psDisplayAllDialogs/ALL )
, Photoshop
will show all user related dialogs. This is typically not what you want.
If you set
display dialogs
to
error dialogs (DisplayErrorDialogs/ERROR)
,
then only dialogs related to errors are shown. You would typically use this setting when you
are developing a script or if your script is an interactive one that expects a user to be sitting at
the machine while running the script.
If you set
display dialogs
to
never ( DisplayNoDialogs/NO ),
then no dialogs
are shown. If an error occurs it will be returned as an error to the script. See section
2.10.4,
“Error handling” on page 29
for more information on catching errors.