Adobe 23101335 Scripting Guide - Page 52

never DisplayNoDialogs/NO

Page 52 highlights

Scripting Photoshop 3 The Application object 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 unsupervisored (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 31 for more information on catching errors. Opening a document When using the open command there are a number of specifiable options. These options are grouped by file type in the provided open options classes. Because the type and contents of the file you are working on affects how it is opened, some of the option values may not always be applicable. It also means that many of the option values do not have well defined default values. The best way to determine what values can or should be used for open is to perform an open command from the user interface. You can then copy the value from the options dialog to your script. You should perform a complete open operation because there can be multiple dialogs presented before the document is actually opened. If you cancel one of the open dialogs without completing the operation you could miss seeing a dialog which contains values needed in your script. Specifying file formats to open Because Photoshop supports many different file formats, the Open command lets you specify the format of the document you are opening. If you do not specify the format, Photoshop will infer the type of file for you. Here's how to open a document using its default type: AS: set theFile to alias "MyFile.psd" open theFile VB: fileName = "C:\MyFile.psd" Set docRef = appRef.Open(fileName) Photoshop 7.0 Scripting Guide 52

  • 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
52
Scripting Photoshop
The Application object
3
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
unsupervisored (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 31
for more information on catching errors.
Opening a document
When using the open command there are a number of specifiable options. These options are
grouped by file type in the provided open options classes. Because the type and contents of the
file you are working on affects how it is opened, some of the option values may not always be
applicable. It also means that many of the option values do not have well defined default
values.
The best way to determine what values can or should be used for open is to perform an open
command from the user interface. You can then copy the value from the options dialog to your
script. You should perform a complete open operation because there can be multiple dialogs
presented before the document is actually opened. If you cancel one of the open dialogs
without completing the operation you could miss seeing a dialog which contains values
needed in your script.
Specifying file formats to open
Because Photoshop supports many different file formats, the
Open
command lets you specify
the format of the document you are opening. If you do not specify the format, Photoshop will
infer the type of file for you. Here’s how to open a document using its default type:
AS:
set theFile to alias "MyFile.psd"
open theFile
VB:
fileName = "C:\MyFile.psd"
Set docRef = appRef.Open(fileName)