Adobe 23101335 Scripting Guide - Page 21

The Scripts menu, 2.9.1 Scripts folder, 2.9.2 The scripts dialog box

Page 21 highlights

VB Private Sub ScriptSample_Click(Index As Integer) result = DoConfirm("Are you sure?") MsgBox (result) End Sub Function DoConfirm(prompt) As Boolean buttonPressed = MsgBox(prompt, vbYesNo) DoConfirm = (buttonPressed = vbYes) End Function JS var theResult = DoConfirm( "Are you sure?" ); alert(theResult); function DoConfirm(message) { var result = confirm(message); return result; } Scripting basics 2 The Scripts menu 2.9 The Scripts menu The Scripts menu item is located in the File > Automate menu. When the Scripts... item is selected, a dialog is presented from which you can select a JavaScript for execution. The scripts listed in the dialog are in the Scripts folder 2.9.1 Scripts folder The Scripts folder is in the Photoshop/Presets folder. This folder is created during Scripting Support functionality installation. All JavaScript files placed in the Scripts folder will be available for execution from the Scripts Dialog. Only those script files found in the root of the folder will be listed. Any files in subfolders will be ignored and not listed in the dialog. For both Mac and Windows, a JavaScript file must be saved as a text file with a '.js' file name extension. 2.9.2 The scripts dialog box To execute a script, select it from the list of scripts and click the "Run Script" button. If there is an error encountered during script execution, an error dialog will be displayed containing the error message returned by the script. If you hold down the option key (alt for Windows), the Photoshop 7.0 Scripting Guide 21

  • 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
21
Scripting basics
The Scripts menu
2
VB
Private Sub ScriptSample_Click(Index As Integer)
result = DoConfirm("Are you sure?")
MsgBox (result)
End Sub
Function DoConfirm(prompt) As Boolean
buttonPressed = MsgBox(prompt, vbYesNo)
DoConfirm = (buttonPressed = vbYes)
End Function
JS
var theResult = DoConfirm( "Are you sure?" );
alert(theResult);
function DoConfirm(message)
{
var result = confirm(message);
return result;
}
2.9 The Scripts menu
The Scripts menu item is located in the
File > Automate
menu. When the
Scripts...
item is selected, a dialog is presented from which you can select a JavaScript for execution.
The scripts listed in the dialog are in the Scripts folder
2.9.1 Scripts folder
The Scripts folder is in the Photoshop/Presets folder. This folder is created during Scripting
Support functionality installation. All JavaScript files placed in the Scripts folder will be
available for execution from the Scripts Dialog. Only those script files found in the root of the
folder will be listed. Any files in subfolders will be ignored and not listed in the dialog. For
both Mac and Windows, a JavaScript file must be saved as a text file with a '.js' file name
extension.
2.9.2 The scripts dialog box
To execute a script, select it from the list of scripts and click the “Run Script” button. If there is
an error encountered during script execution, an error dialog will be displayed containing the
error message returned by the script. If you hold down the option key (alt for Windows), the