rb-appscript 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +30 -0
- data/LICENSE +1 -1
- data/README +7 -3
- data/TODO +7 -1
- data/doc/aem-manual/01_introduction.html +23 -9
- data/doc/aem-manual/02_apioverview.html +25 -11
- data/doc/aem-manual/03_packingandunpackingdata.html +22 -17
- data/doc/aem-manual/04_references.html +49 -36
- data/doc/aem-manual/05_targettingapplications.html +25 -14
- data/doc/aem-manual/06_buildingandsendingevents.html +47 -21
- data/doc/aem-manual/07_findapp.html +22 -11
- data/doc/aem-manual/08_examples.html +21 -10
- data/doc/aem-manual/index.html +28 -12
- data/doc/appscript-manual/01_introduction.html +40 -27
- data/doc/appscript-manual/02_aboutappscripting.html +28 -15
- data/doc/appscript-manual/03_quicktutorial.html +29 -16
- data/doc/appscript-manual/04_gettinghelp.html +31 -16
- data/doc/appscript-manual/05_keywordconversion.html +23 -10
- data/doc/appscript-manual/06_classesandenums.html +32 -19
- data/doc/appscript-manual/07_applicationobjects.html +31 -18
- data/doc/appscript-manual/08_realvsgenericreferences.html +23 -11
- data/doc/appscript-manual/09_referenceforms.html +33 -20
- data/doc/appscript-manual/10_referenceexamples.html +30 -17
- data/doc/appscript-manual/11_applicationcommands.html +25 -13
- data/doc/appscript-manual/12_commandexamples.html +26 -15
- data/doc/appscript-manual/13_performanceissues.html +46 -20
- data/doc/appscript-manual/14_notes.html +29 -19
- data/doc/appscript-manual/index.html +27 -11
- data/doc/full.css +95 -9
- data/doc/index.html +27 -10
- data/doc/mactypes-manual/01_introduction.html +56 -0
- data/doc/mactypes-manual/02_aliasclass.html +134 -0
- data/doc/mactypes-manual/03_fileurlclass.html +136 -0
- data/doc/mactypes-manual/04_unitsclass.html +102 -0
- data/doc/mactypes-manual/index.html +26 -227
- data/doc/osax-manual/01_introduction.html +69 -0
- data/doc/osax-manual/02_interface.html +149 -0
- data/doc/osax-manual/03_examples.html +75 -0
- data/doc/osax-manual/04_notes.html +80 -0
- data/doc/osax-manual/index.html +26 -195
- data/doc/rb-appscript-logo.png +0 -0
- data/rb-appscript.gemspec +2 -2
- data/sample/TextEdit_demo.rb +1 -1
- data/src/lib/_aem/aemreference.rb +1 -1
- data/src/lib/_aem/codecs.rb +42 -8
- data/src/lib/_aem/connect.rb +3 -1
- data/src/lib/_aem/findapp.rb +1 -1
- data/src/lib/_aem/mactypes.rb +1 -1
- data/src/lib/_aem/send.rb +162 -142
- data/src/lib/_aem/typewrappers.rb +2 -2
- data/src/lib/_appscript/defaultterminology.rb +76 -46
- data/src/lib/_appscript/referencerenderer.rb +1 -1
- data/src/lib/_appscript/reservedkeywords.rb +2 -2
- data/src/lib/_appscript/safeobject.rb +1 -1
- data/src/lib/_appscript/terminology.rb +30 -19
- data/src/lib/aem.rb +1 -6
- data/src/lib/appscript.rb +65 -20
- data/src/lib/osax.rb +21 -18
- data/src/rbae.c +1 -1
- data/test/test_appscriptcommands.rb +1 -1
- metadata +12 -3
@@ -2,7 +2,7 @@
|
|
2
2
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
3
|
<head>
|
4
4
|
|
5
|
-
<title>appscript | 7. Application Objects</title>
|
5
|
+
<title>rb-appscript manual | 7. Application Objects</title>
|
6
6
|
|
7
7
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
8
8
|
<style type="text/css" media="all"><!--@import url(../full.css);--></style>
|
@@ -10,17 +10,28 @@
|
|
10
10
|
</head>
|
11
11
|
<body>
|
12
12
|
|
13
|
-
<h1
|
13
|
+
<h1><img src="../rb-appscript-logo.png" alt="rb-appscript" title="rb-appscript" /></h1>
|
14
14
|
|
15
15
|
<!-- top navigation -->
|
16
16
|
<div class="navbar">
|
17
|
-
|
18
|
-
|
17
|
+
<a href="06_classesandenums.html">Previous</a> •
|
18
|
+
<a href="index.html">Up</a> •
|
19
|
+
<a href="08_realvsgenericreferences.html">Next</a>
|
20
|
+
|
21
|
+
<span>
|
22
|
+
<strong><a href="../appscript-manual/index.html">appscript</a></strong> /
|
23
|
+
<a href="../mactypes-manual/index.html">mactypes</a> /
|
24
|
+
<a href="../osax-manual/index.html">osax</a> /
|
25
|
+
<a href="../aem-manual/index.html">aem</a>
|
26
|
+
</span>
|
19
27
|
</div>
|
20
28
|
|
21
29
|
<!-- content -->
|
22
30
|
<div id="content">
|
23
|
-
|
31
|
+
|
32
|
+
<h2>7. Application Objects</h2>
|
33
|
+
|
34
|
+
<h3>Creating application objects</h3>
|
24
35
|
|
25
36
|
|
26
37
|
<p>Before you can communicate with a scriptable application you must call one of the following methods to create an application object:</p>
|
@@ -87,7 +98,7 @@ finder = app.by_url('eppc://192.168.10.1/Finder')
|
|
87
98
|
itunes = app.by_url('eppc://Jan%20Smith@G4.local/iTunes')</code></pre>
|
88
99
|
|
89
100
|
|
90
|
-
<
|
101
|
+
<h3>Basic commands</h3>
|
91
102
|
|
92
103
|
<p>All applications should respond to the following commands:</p>
|
93
104
|
|
@@ -129,7 +140,7 @@ set(reference, :to => value) -- Set an object's data.
|
|
129
140
|
<p>Note that these commands are only useful in applications that define an Apple Event Object Model as part of their Apple event interface.</p>
|
130
141
|
|
131
142
|
|
132
|
-
<
|
143
|
+
<h3>Transaction support</h3>
|
133
144
|
|
134
145
|
<p>Application objects implement three additional methods, <code>begin_transaction</code>, <code>end_transaction</code> and <code>abort_transaction</code> that allow a sequence of related commands to be handled as a single operation by applications that support transactions, e.g. FileMaker Pro.</p>
|
135
146
|
|
@@ -140,19 +151,19 @@ set(reference, :to => value) -- Set an object's data.
|
|
140
151
|
<p class="hilitebox">Remember to call <code>end_transaction</code> or <code>abort_transaction</code> at the end of every transaction. (This includes transactions interrupted by a raised exception.) If a transaction is accidentally left open, appscript will try to end it automatically when the application object is garbage-collected, but this is not guaranteed to succeed.</p>
|
141
152
|
|
142
153
|
|
143
|
-
<
|
154
|
+
<h3>Local application launching notes</h3>
|
144
155
|
|
145
156
|
<p>Note: the following information only applies to local applications as appscript cannot directly launch applications on a remote Mac. To control a remote application, the application must be running beforehand or else launched indirectly (e.g. by using the remote Mac's Finder to open it).</p>
|
146
157
|
|
147
158
|
|
148
|
-
<
|
159
|
+
<h4>How applications are identified</h4>
|
149
160
|
|
150
161
|
<p>When you create an Application object by application name, bundle id or creator type, appscript uses LaunchServices to locate an application matching that description. If you have more than one copy of the same application installed, you can identify the one you want by providing its full path, otherwise LaunchServices will identify the newest copy for you.</p>
|
151
162
|
|
152
163
|
<p>Appscript identifies running applications by their process ids so it's possible to control multiple versions of an application running at the same time if their Application objects are created using process ids or eppc URLs.</p>
|
153
164
|
|
154
165
|
|
155
|
-
<
|
166
|
+
<h4>Checking if an application is running</h4>
|
156
167
|
|
157
168
|
<p>You can check if the application specified by an Application object is currently running by calling its <code>#is_running?</code> method. This is useful if you don't want to perform commands on an application that isn't already running. For example:</p>
|
158
169
|
|
@@ -165,12 +176,12 @@ end</code></pre>
|
|
165
176
|
<p class="hilitebox">Remember that appscript automatically launches a non-running application the first time your script makes reference to any of its properties, elements or commands. To avoid accidental launches, <em>all</em> code relating to that application must be included in a conditional block that only executes if <code>#is_running?</code> returns <code>true</code>.</p>
|
166
177
|
|
167
178
|
|
168
|
-
<
|
179
|
+
<h4>Launch errors</h4>
|
169
180
|
|
170
181
|
<p>If the application can't be launched for some reason (e.g. if it's in the Trash), an <code>Appscript::CantLaunchApplicationError</code> error will be raised. This provides a description of the problem (if it's a standard LaunchServices error) along with the original OS error number, which you can also obtain via the <code>CantLaunchApplicationError#to_i</code> method.</p>
|
171
182
|
|
172
183
|
|
173
|
-
<
|
184
|
+
<h4>Using <code>launch</code> vs <code>run</code></h4>
|
174
185
|
|
175
186
|
<p>When appscript launches a non-running application, it normally sends it a <code>run</code> command as part of the launching process. If you wish to avoid this, you should start the application by sending it a <code>launch</code> command before doing anything else. For example:</p>
|
176
187
|
|
@@ -183,7 +194,7 @@ te.launch
|
|
183
194
|
<p><code>launch</code> is also useful if you need to send a non-running application an <code>open</code> command as its very first instruction. For example, to send an <code>open</code> command to a non-stay-open application that batch processes one or more dropped files then quits again, you must first start it using <code>launch</code>, then send it an <code>open</code> command with the files to process. If you forget to do this, the application will first receive a <code>run</code> command and quit again before the <code>open</code> command can be handled.</p>
|
184
195
|
|
185
196
|
|
186
|
-
<
|
197
|
+
<h4>Restarting applications</h4>
|
187
198
|
|
188
199
|
<p>As soon as you start to construct a reference or command using a newly created Application objects, if the application is not already running then appscript will automatically launch it in order to obtain its terminology.</p>
|
189
200
|
|
@@ -198,12 +209,14 @@ te.launch
|
|
198
209
|
</div>
|
199
210
|
|
200
211
|
<!-- bottom navigation -->
|
201
|
-
|
202
|
-
|
203
|
-
|
212
|
+
|
213
|
+
<div class="footer">
|
214
|
+
<a href="06_classesandenums.html">Previous</a> •
|
215
|
+
<a href="index.html">Up</a> •
|
216
|
+
<a href="08_realvsgenericreferences.html">Next</a>
|
217
|
+
|
218
|
+
<span>© 2006-2008 HAS</span>
|
204
219
|
</div>
|
205
220
|
|
206
|
-
<!--footer-->
|
207
|
-
<p class="footer">© 2006-2008 HAS</p>
|
208
221
|
</body>
|
209
222
|
</html>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
3
|
<head>
|
4
4
|
|
5
|
-
<title>appscript | 8. Real vs. Generic References</title>
|
5
|
+
<title>rb-appscript manual | 8. Real vs. Generic References</title>
|
6
6
|
|
7
7
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
8
8
|
<style type="text/css" media="all"><!--@import url(../full.css);--></style>
|
@@ -10,18 +10,28 @@
|
|
10
10
|
</head>
|
11
11
|
<body>
|
12
12
|
|
13
|
-
<h1
|
13
|
+
<h1><img src="../rb-appscript-logo.png" alt="rb-appscript" title="rb-appscript" /></h1>
|
14
14
|
|
15
15
|
<!-- top navigation -->
|
16
16
|
<div class="navbar">
|
17
|
-
|
18
|
-
|
17
|
+
<a href="07_applicationobjects.html">Previous</a> •
|
18
|
+
<a href="index.html">Up</a> •
|
19
|
+
<a href="09_referenceforms.html">Next</a>
|
20
|
+
|
21
|
+
<span>
|
22
|
+
<strong><a href="../appscript-manual/index.html">appscript</a></strong> /
|
23
|
+
<a href="../mactypes-manual/index.html">mactypes</a> /
|
24
|
+
<a href="../osax-manual/index.html">osax</a> /
|
25
|
+
<a href="../aem-manual/index.html">aem</a>
|
26
|
+
</span>
|
19
27
|
</div>
|
20
28
|
|
21
29
|
<!-- content -->
|
22
30
|
<div id="content">
|
23
31
|
|
24
|
-
<h2>Real vs.
|
32
|
+
<h2>8. Real vs. Generic References</h2>
|
33
|
+
|
34
|
+
<h3>Real vs. generic references</h3>
|
25
35
|
|
26
36
|
<p>References may be either 'real' or 'generic'. A real reference relates to a specific application, while a generic reference doesn't. Generic references provide a convenient shortcut for writing literal references without having to specify an application each time.</p>
|
27
37
|
|
@@ -55,7 +65,7 @@ app('Finder').desktop.duplicate(
|
|
55
65
|
:to => <em>app.home.folders['Desktop Copy']</em>)</code></pre>
|
56
66
|
|
57
67
|
|
58
|
-
<
|
68
|
+
<h3>Comparing and hashing references</h3>
|
59
69
|
|
60
70
|
<p>Application references can be compared for equality and are hashable (so can be used as dictionary keys). For two real references to be considered equal, both must have the same application path or url and reference structure. Examples:</p>
|
61
71
|
|
@@ -75,12 +85,14 @@ puts app('Finder').home == app('Finder').home.get
|
|
75
85
|
</div>
|
76
86
|
|
77
87
|
<!-- bottom navigation -->
|
78
|
-
|
79
|
-
|
80
|
-
|
88
|
+
|
89
|
+
<div class="footer">
|
90
|
+
<a href="07_applicationobjects.html">Previous</a> •
|
91
|
+
<a href="index.html">Up</a> •
|
92
|
+
<a href="09_referenceforms.html">Next</a>
|
93
|
+
|
94
|
+
<span>© 2006-2008 HAS</span>
|
81
95
|
</div>
|
82
96
|
|
83
|
-
<!--footer-->
|
84
|
-
<p class="footer">© 2006-2008 HAS</p>
|
85
97
|
</body>
|
86
98
|
</html>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
3
|
<head>
|
4
4
|
|
5
|
-
<title>appscript | 9. Reference Forms</title>
|
5
|
+
<title>rb-appscript manual | 9. Reference Forms</title>
|
6
6
|
|
7
7
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
8
8
|
<style type="text/css" media="all"><!--@import url(../full.css);--></style>
|
@@ -10,17 +10,28 @@
|
|
10
10
|
</head>
|
11
11
|
<body>
|
12
12
|
|
13
|
-
<h1
|
13
|
+
<h1><img src="../rb-appscript-logo.png" alt="rb-appscript" title="rb-appscript" /></h1>
|
14
14
|
|
15
15
|
<!-- top navigation -->
|
16
16
|
<div class="navbar">
|
17
|
-
|
18
|
-
|
17
|
+
<a href="08_realvsgenericreferences.html">Previous</a> •
|
18
|
+
<a href="index.html">Up</a> •
|
19
|
+
<a href="10_referenceexamples.html">Next</a>
|
20
|
+
|
21
|
+
<span>
|
22
|
+
<strong><a href="../appscript-manual/index.html">appscript</a></strong> /
|
23
|
+
<a href="../mactypes-manual/index.html">mactypes</a> /
|
24
|
+
<a href="../osax-manual/index.html">osax</a> /
|
25
|
+
<a href="../aem-manual/index.html">aem</a>
|
26
|
+
</span>
|
19
27
|
</div>
|
20
28
|
|
21
29
|
<!-- content -->
|
22
30
|
<div id="content">
|
23
|
-
|
31
|
+
|
32
|
+
<h2>9. Reference Forms</h2>
|
33
|
+
|
34
|
+
<h3>Property reference</h3>
|
24
35
|
|
25
36
|
<p>A property either contains a simple value or represents a one-to-one relationship between two application objects. Properties either describe the application object (its name, class, size, color, preferences, etc.) or provide a convenient reference to other object(s) of interest to users (e.g. home, current_track).</p>
|
26
37
|
|
@@ -34,11 +45,11 @@ finder.<em>home</em>.files.<em>name</em></code></pre>
|
|
34
45
|
|
35
46
|
|
36
47
|
|
37
|
-
<
|
48
|
+
<h3>Element references</h3>
|
38
49
|
|
39
50
|
<p>Elements represent a one-to-many relationship between application objects. Elements usually reflect the containment structure of the application object model and generally provide multiple ways of referencing some or all of those objects (e.g. characters/words/paragraphs of documents by index/relative-position/range/filter).</p>
|
40
51
|
|
41
|
-
<
|
52
|
+
<h4>All Elements</h4>
|
42
53
|
|
43
54
|
<p>Syntax:</p>
|
44
55
|
<pre><code>reference.elements</code></pre>
|
@@ -49,7 +60,7 @@ textedit.<em>windows</em>
|
|
49
60
|
textedit.<em>documents</em>.<em>paragraphs</em>.<em>words</em></code></pre>
|
50
61
|
|
51
62
|
|
52
|
-
<
|
63
|
+
<h4>by Name</h4>
|
53
64
|
|
54
65
|
<p>Syntax:</p>
|
55
66
|
<pre><code>elements[selector]
|
@@ -62,7 +73,7 @@ files['index.html']</code></pre>
|
|
62
73
|
<p class="hilitebox">Note: applications usually treat object names as case-insensitive. Where multiple element have the same name, a by-name reference only identifies the first element found with that name. (Tip: to identify <em>all</em> elements with a particular name, use a by-filter reference instead.)</p>
|
63
74
|
|
64
75
|
|
65
|
-
<
|
76
|
+
<h4>by Index</h4>
|
66
77
|
|
67
78
|
<p>Syntax:</p>
|
68
79
|
<pre><code>elements[selector]
|
@@ -75,7 +86,7 @@ items[-1]</code></pre>
|
|
75
86
|
<p class="hilitebox">Note: elements are <em>one-indexed</em> (AEM-style indexing), not zero-indexed (Ruby-style indexing).</p>
|
76
87
|
|
77
88
|
|
78
|
-
<
|
89
|
+
<h4>by ID</h4>
|
79
90
|
|
80
91
|
<p>Syntax:</p>
|
81
92
|
<pre><code>elements.ID(selector)
|
@@ -85,7 +96,7 @@ items[-1]</code></pre>
|
|
85
96
|
<pre><code>windows.ID(4321)</code></pre>
|
86
97
|
|
87
98
|
|
88
|
-
<
|
99
|
+
<h4>by Absolute Position</h4>
|
89
100
|
|
90
101
|
<p>Syntax:</p>
|
91
102
|
<pre><code>elements.first -- first element
|
@@ -99,7 +110,7 @@ paragraphs.last
|
|
99
110
|
files.any</code></pre>
|
100
111
|
|
101
112
|
|
102
|
-
<
|
113
|
+
<h4>by Relative Position</h4>
|
103
114
|
|
104
115
|
<p>Syntax:</p>
|
105
116
|
<pre><code>elements[selector].previous(class) -- nearest element of a given class to appear
|
@@ -113,7 +124,7 @@ elements[selector].next(class) -- nearest element of a given class to appear
|
|
113
124
|
paragraphs[-1].previous(:character)</code></pre>
|
114
125
|
|
115
126
|
|
116
|
-
<
|
127
|
+
<h4>by Range</h4>
|
117
128
|
|
118
129
|
<p>Range references select all elements between and including two references indicating the start and stop of the range. The start and stop references are normally declared relative to the container of the elements being selected. Appscript defines an object, <code>con</code> (short for 'container'), to indicate this container; for example, to indicate the third paragraph of the currrent container object:</p>
|
119
130
|
|
@@ -143,7 +154,7 @@ text[con.characters[5], con.words[-2]]</code></pre>
|
|
143
154
|
|
144
155
|
<p class="hilitebox">Note: ranges are specified as [start-position, <em>stop-position</em>] (AEM-style ranges), not [start-position, <em>length</em>] (Ruby-style ranges).</p>
|
145
156
|
|
146
|
-
<
|
157
|
+
<h4>by Filter</h4>
|
147
158
|
|
148
159
|
<p>A reference to each element that satisfies one or more conditions specified by a test expression:</p>
|
149
160
|
|
@@ -200,7 +211,7 @@ its.words[1].begins_with('A').or(
|
|
200
211
|
|
201
212
|
|
202
213
|
|
203
|
-
<
|
214
|
+
<h3>Insertion location</h3>
|
204
215
|
|
205
216
|
<p>Insertion locations can be specified at the beginning or end of all elements, or before or after a specified element or element range.</p>
|
206
217
|
|
@@ -219,12 +230,14 @@ paragraphs[1].before</code></pre>
|
|
219
230
|
</div>
|
220
231
|
|
221
232
|
<!-- bottom navigation -->
|
222
|
-
|
223
|
-
|
224
|
-
|
233
|
+
|
234
|
+
<div class="footer">
|
235
|
+
<a href="08_realvsgenericreferences.html">Previous</a> •
|
236
|
+
<a href="index.html">Up</a> •
|
237
|
+
<a href="10_referenceexamples.html">Next</a>
|
238
|
+
|
239
|
+
<span>© 2006-2008 HAS</span>
|
225
240
|
</div>
|
226
241
|
|
227
|
-
<!--footer-->
|
228
|
-
<p class="footer">© 2006-2008 HAS</p>
|
229
242
|
</body>
|
230
243
|
</html>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
3
|
<head>
|
4
4
|
|
5
|
-
<title>appscript | 10. Reference Examples</title>
|
5
|
+
<title>rb-appscript manual | 10. Reference Examples</title>
|
6
6
|
|
7
7
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
8
8
|
<style type="text/css" media="all"><!--@import url(../full.css);--></style>
|
@@ -10,17 +10,28 @@
|
|
10
10
|
</head>
|
11
11
|
<body>
|
12
12
|
|
13
|
-
<h1
|
13
|
+
<h1><img src="../rb-appscript-logo.png" alt="rb-appscript" title="rb-appscript" /></h1>
|
14
14
|
|
15
15
|
<!-- top navigation -->
|
16
16
|
<div class="navbar">
|
17
|
-
|
18
|
-
|
17
|
+
<a href="09_referenceforms.html">Previous</a> •
|
18
|
+
<a href="index.html">Up</a> •
|
19
|
+
<a href="11_applicationcommands.html">Next</a>
|
20
|
+
|
21
|
+
<span>
|
22
|
+
<strong><a href="../appscript-manual/index.html">appscript</a></strong> /
|
23
|
+
<a href="../mactypes-manual/index.html">mactypes</a> /
|
24
|
+
<a href="../osax-manual/index.html">osax</a> /
|
25
|
+
<a href="../aem-manual/index.html">aem</a>
|
26
|
+
</span>
|
19
27
|
</div>
|
20
28
|
|
21
29
|
<!-- content -->
|
22
30
|
<div id="content">
|
23
|
-
|
31
|
+
|
32
|
+
<h2>10. Reference Examples</h2>
|
33
|
+
|
34
|
+
<h3>Application objects</h3>
|
24
35
|
|
25
36
|
<pre><code>require "appscript"
|
26
37
|
include Appscript
|
@@ -32,7 +43,7 @@ app('Finder')
|
|
32
43
|
app('/Applications/TextEdit.app')</code></pre>
|
33
44
|
|
34
45
|
|
35
|
-
<
|
46
|
+
<h3>Property references</h3>
|
36
47
|
|
37
48
|
<pre><code># a reference to startup disk of application "Finder"
|
38
49
|
app('Finder').startup_disk
|
@@ -51,7 +62,7 @@ app('TextEdit').documents.text
|
|
51
62
|
app('TextEdit').documents[1].text.paragraphs.characters[1].color</code></pre>
|
52
63
|
|
53
64
|
|
54
|
-
<
|
65
|
+
<h3>All elements references</h3>
|
55
66
|
|
56
67
|
<pre><code># a reference to disks of application "Finder"
|
57
68
|
app('Finder').disks
|
@@ -61,7 +72,7 @@ app('Finder').disks
|
|
61
72
|
app('TextEdit').documents.text.paragraphs.words</code></pre>
|
62
73
|
|
63
74
|
|
64
|
-
<
|
75
|
+
<h3>Single element references</h3>
|
65
76
|
|
66
77
|
<pre><code># a reference to disk 1 of application "Finder"
|
67
78
|
app('Finder').disks[1]
|
@@ -79,7 +90,7 @@ app('TextEdit').documents.last.text.paragraphs.middle
|
|
79
90
|
app('Finder').home.files.any</code></pre>
|
80
91
|
|
81
92
|
|
82
|
-
<
|
93
|
+
<h3>Relative references</h3>
|
83
94
|
|
84
95
|
<pre><code># a reference to paragraph before paragraph 6 of text of document 1 of application "TextEdit"
|
85
96
|
app('TextEdit').documents[1].text.paragraphs[6].previous(:paragraph)
|
@@ -88,7 +99,7 @@ app('TextEdit').documents[1].text.paragraphs[6].previous(:paragraph)
|
|
88
99
|
app('Tex-Edit Plus').documents[1].characters[30].next(:paragraph)</code></pre>
|
89
100
|
|
90
101
|
|
91
|
-
<
|
102
|
+
<h3>Element range references</h3>
|
92
103
|
|
93
104
|
<pre><code># a reference to words 1 thru 4 of text of document 1 of application "TextEdit"
|
94
105
|
app('TextEdit').documents[1].text.words[1, 4]
|
@@ -103,7 +114,7 @@ app('Finder').home.folders['Documents', 'Music']
|
|
103
114
|
app('Tex-Edit Plus').documents[1].text[con.words[3], con.paragraphs[7]]</code></pre>
|
104
115
|
|
105
116
|
|
106
|
-
<
|
117
|
+
<h3>Filter references</h3>
|
107
118
|
|
108
119
|
<pre><code># a reference to every document of application "TextEdit" whose text is "\n"
|
109
120
|
app('TextEdit').documents[its.text.eq("\n")]
|
@@ -119,7 +130,7 @@ app('Finder').home.folders['Documents'].files[
|
|
119
130
|
its.name_extension.eq('txt').AND(its.size.lt(10240))]</code></pre>
|
120
131
|
|
121
132
|
|
122
|
-
<
|
133
|
+
<h3>Insertion location references</h3>
|
123
134
|
|
124
135
|
<pre><code># a reference to end of documents of application "TextEdit"
|
125
136
|
app('TextEdit').documents.end
|
@@ -132,12 +143,14 @@ app('TextEdit').documents[1].text.paragraphs[1].before</code></pre>
|
|
132
143
|
</div>
|
133
144
|
|
134
145
|
<!-- bottom navigation -->
|
135
|
-
|
136
|
-
|
137
|
-
|
146
|
+
|
147
|
+
<div class="footer">
|
148
|
+
<a href="09_referenceforms.html">Previous</a> •
|
149
|
+
<a href="index.html">Up</a> •
|
150
|
+
<a href="11_applicationcommands.html">Next</a>
|
151
|
+
|
152
|
+
<span>© 2006-2008 HAS</span>
|
138
153
|
</div>
|
139
154
|
|
140
|
-
<!--footer-->
|
141
|
-
<p class="footer">© 2006-2008 HAS</p>
|
142
155
|
</body>
|
143
156
|
</html>
|