Adobe 27510753 Scripting Guide - Page 49

Using the Script Label palette

Page 49 highlights

Adobe InDesign CS2 Scripting Guide Getting Started with InDesign Scripting 41 run a script using the Scripts palette, InDesign suppresses screen drawing until the script has finished. To view the script actions as they execute, choose Enable Redraw from the Scripts palette menu. l To edit a script shown in the Scripts palette, hold down Option (Mac OS) or Alt (Windows) and double-click the script's name. This opens the script in the editor you've defined for the file type. l To open the folder containing a script shown in the Scripts palette, hold down Command (Mac OS) or Ctrl (Windows) and double-click the script's name, or choose Reveal in Finder (Mac OS) or Reveal in Explorer (Windows) from the Scripts palette menu. The folder containing the script opens in the Finder (Mac OS) or Explorer (Windows). l To open a JavaScript in the ExtendScript Toolkit debugger, hold down Shift as you double-click the script's name in the Scripts palette. See Chapter 4, "Using ExtendScript Tools and Features," for more information. l To add a keyboard shortcut for a script, choose Edit > KeyboardShortcuts, select an editable shortcut set from the Set menu, then select Scripts from the Product Area menu. A list of the scripts in your Scripts palette appears. Select a script and assign a keyboard shortcut as you would for any other InDesign feature. Using the Script Label palette Many of the objects in the InDesign object model have a label property-it's a property that can be set to any string of up to 32 KB of text. The main purpose of the label property is to identify objects so that scripts can act on them. One way to assign a label to an object is to use the Script Label palette (choose Window > Automation > Script Label). If the Script Label palette is not available, it's because the plug-in is not installed or has been disabled. Use the plug-in manager to enable the plug-in, or reinstall the palette. Access the plug-in manager using Help > Configure Plug-Ins in Windows or InDesign > Configure Plug-Ins in Mac OS . The following examples show how to get a reference to a page item with a specific label. AppleScript --Given a reference to a page "myPage" containing a text frame with the label "myTargetFrame" tell myPage set myTextFrame to text frame "myTargetFrame" end if VBScript Rem Given a reference to a page "myPage" containing a text frame with the label "myTargetFrame" Set myTextFrame = myPage.TextFrames.Item("myTargetFrame") JavaScript // Assuming that the first page of the active document contains // a text frame with the label "myTargetFrame" with(app.documents.item(0).pages.item(0)){ myTargetFrame = textFrames.item("myTargetFrame"); }

  • 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
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184

Adobe InDesign CS2 Scripting Guide
Getting Started with InDesign Scripting
41
run a script using the Scripts palette, InDesign suppresses screen drawing until the script has finished. To
view the script actions as they execute, choose Enable Redraw from the Scripts palette menu.
To edit a script shown in the Scripts palette, hold down Option (Mac OS) or Alt (Windows) and double-click
the script’s name. This opens the script in the editor you’ve defined for the file type.
To open the folder containing a script shown in the Scripts palette, hold down Command (Mac OS) or Ctrl
(Windows) and double-click the script’s name, or choose Reveal in Finder (Mac OS) or Reveal in Explorer
(Windows) from the Scripts palette menu. The folder containing the script opens in the Finder (Mac OS) or
Explorer (Windows).
To open a JavaScript in the ExtendScript Toolkit debugger, hold down Shift as you double-click the script's
name in the Scripts palette. See Chapter 4, “Using ExtendScript Tools and Features,” for more information.
To add a keyboard shortcut for a script, choose Edit > KeyboardShortcuts, select an editable shortcut set
from the Set menu, then select Scripts from the Product Area menu. A list of the scripts in your Scripts pal-
ette appears. Select a script and assign a keyboard shortcut as you would for any other InDesign feature.
Using the Script Label palette
Many of the objects in the InDesign object model have a label property—it’s a property that can be set to
any string of up to 32 KB of text. The main purpose of the label property is to identify objects so that scripts
can act on them. One way to assign a label to an object is to use the Script Label palette (choose Window >
Automation > Script Label).
If the Script Label palette is not available, it’s because the plug-in is not installed or has been disabled. Use
the plug-in manager to enable the plug-in, or reinstall the palette. Access the plug-in manager using Help >
Configure Plug-Ins in Windows or InDesign > Configure Plug-Ins in Mac OS .
The following examples show how to get a reference to a page item with a specific label.
AppleScript
--Given a reference to a page "myPage" containing a text frame with the label "myTargetFrame"
tell myPage
set myTextFrame to text frame "myTargetFrame"
end if
VBScript
Rem Given a reference to a page "myPage" containing a text frame with the label "myTargetFrame"
Set myTextFrame = myPage.TextFrames.Item("myTargetFrame")
JavaScript
// Assuming that the first page of the active document contains
// a text frame with the label "myTargetFrame"
with(app.documents.item(0).pages.item(0)){
myTargetFrame = textFrames.item("myTargetFrame");
}
l
l
l
l