This repository has been archived by the owner on Oct 18, 2022. It is now read-only.
forked from autotouch-community/autotouch-document-dist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.html
430 lines (393 loc) · 93.3 KB
/
doc.html
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
<!doctypehtml><meta charset="UTF-8"><meta name="viewport"content="width=device-widthinitial-scale=1"><link rel="stylesheet"href="css/github-markdown.css"><link rel="stylesheet"href="css/normalize.css"><link href="css/style.css"rel="stylesheet"type="text/css"><link rel="apple-touch-icon"sizes="180x180"href="img/favicon/apple-touch-icon.png"><link rel="icon"type="image/png"sizes="32x32"href="img/favicon/favicon-32x32.png"><link rel="icon"type="image/png"sizes="16x16"href="img/favicon/favicon-16x16.png"><link rel="manifest"href="img/favicon/site.webmanifest"><link href="css/prism.css"rel="stylesheet"><style>.markdown-body{box-sizing:border-box;min-width:200px;max-width:980px;margin:0 auto;padding:45px}@media (max-width:767px){.markdown-body{padding:15px}}</style><title>AutoTouch Documentation</title><body class="markdown-body"><h1 id="title">AutoTouch Documentation</h1><p><code>Applicable for v5.0.6 and above</code><blockquote><ul><li>AutoTouch is a 'Macro' tool used to record and playback human-like inputs on an IOS device.<li>It is able simulate touch and key presses, through Lua scripting.<li>It has several extended functions to help you achieve automation.<li>It provides a Script Store to sell and buy scripts.<li>Requires a supported jailbroken device (jailbreaks on IOS 8 to IOS 12.1.2), uses <a href="https://www.lua.org/manual/5.3/">Lua 5.3.5</a><br></ul><p>Normal releases can be found at <a href="http://apt.autotouch.net"target="_blank"class="url">http://apt.autotouch.net</a>. Beta releases can be found at <a href="http://beta.autotouch.net"target="_blank"class="url">http://beta.autotouch.net</a><p>Note: AutoTouch will also be referred to as 'AT' throughout this document.</blockquote><div class="md-toc"mdtype="toc"><p class="md-toc-content"><span class="md-toc-item md-toc-h1"><a class="md-toc-inner"href="#title">AutoTouch Documentation</a></span> <span class="md-toc-item md-toc-h1"><a class="md-toc-inner"href="#install">Installation</a></span> <span class="md-toc-item md-toc-h1"><a class="md-toc-inner"href="#usage">Usage</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#activatorusage">How do I use Activator with AutoTouch?</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#scriptRecord">How do I record scripts?</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#scriptPlayback">How do I play back a script?</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#playSettings">How do I set play settings for script?</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#screenshots">How do I take a screenshot?</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#scriptWrite">How do I start writing scripts?</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#funcHelper">How do I use the "Function Helper" while writing scripts?</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#scriptWrite">How do I write and manage scripts on a computer?</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#package">What is a package and how do I use it?</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#encrypt">How do I encrypt scripts?</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#store">How do you sell scripts in Script Store?</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#buyScript">How do I download and buy scripts from Script Store?</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#license">How do I buy a AutoTouch license?</a></span> <span class="md-toc-item md-toc-h1"><a class="md-toc-inner"href="#scripting">Scripting</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#tuts">Basis</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#devTools">Development Tools</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#coord">Coordinate, Size and Orientation System</a></span> <span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#extnLib">Extension Libraries</a></span><span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#curl">Lua-cURL</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#luaSocket">LuaSocket</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#luaSec">LuaSec</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#luaSqlite3">luaSqlite3</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#luaFS">LuaFileSystem</a></span><span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#extnFunc">Extension Functions</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#touchDown">touchDown(id, x, y)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#touchUp">touchUp(id, x, y)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#tap">Tap(x, y)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#touchMove">touchMove(id, x, y)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#keyDown">keyDown(keyType)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#keyUp">keyUp(keyType)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#getColor">getColor(x, y)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#getColors">getColors(locations)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#findColor">findColor(color, count, region)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#findColors">findColors(colors, count, region)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#findImage">findImage(imagePath, count, fuzzy, ignoreColors, region)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#findImage2">findImage2(targetImagePath, targetsToFind)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#screenshot">screenshot(filePath, region)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#appRun">appRun(appIdentifier)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#appKill">appKill(appIdentifier)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#appState">appState(appIdentifier)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#rootDir">rootDir()</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#usleep">usleep(microseconds)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#log">log(content)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#alert">alert(message)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#toast">toast(message, delay)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#vibrate">vibrate()</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#playAudio">playAudio(audioFile, times)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#stopAudio">stopAudio()</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#getOrientation">getOrientation()</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#getScreenResolution">getScreenResolution()</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#getSN">getSN()</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#getVersion">getVersion()</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#intToRgb">intToRgb(intColor)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#rgbToInt">rgbToInt(r, g, b)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#copyText">copyText(text)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#clipText">clipText()</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#inputText">inputText(text)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#dialog">dialog(controls, enableRemember)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#clearDialogValues">clearDialogValues(script)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#openURL">openURL(urlString)</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#license">isLicensed()</a></span><span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#playScript">Play a script</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#stopScript">Stop playing a script</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#listDir">List files in directory</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#newDir">Create a new directory</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#newFile">Create a new file</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#delFile">Delete a file</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#rename">Rename a file or directory</a></span><span class="md-toc-item md-toc-h2"><a class="md-toc-inner"href="#constants">Some Constants</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#physicalKeys">Types of physical keys</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#dialogControls">Types of dialog controls</a></span> <span class="md-toc-item md-toc-h3"><a class="md-toc-inner"href="#screenOrientation">Types of screen orientations</a></span></div><p> <p> <h1 id="install">Installation</h1><blockquote><ul><li>You can search and install AutoTouch in Cydia directly from the BigBoss repo.<li>You can also add the official repo: <a href="http://apt.autotouch.net"target="_blank"class="url">http://apt.autotouch.net</a> to Cydia and install AutoTouch there.<li>There is also a beta repo: <a href="http://beta.autotouch.net"target="_blank"class="url">http://beta.autotouch.net</a> which has in-progress builds that can be unstable but features are developed much faster</ul><p>If you are experiencing issues with AutoTouch please first check for updates in Cydia and see if this remedies your issue(s).</blockquote><p> <h1 id="usage">Usage</h1><h2 id="activatorusage">How do I use Activator with AutoTouch? (depends on IOS compatibility)</h2><blockquote><ul><li>By default the AutoTouch menu pops up when the volume down button is held. This default behavior can changed by installing Activator.<li>Add the official repo: <a href="http://rpetri.ch/repo/"target="_blank"class="url">http://rpetri.ch/repo/</a> to Cydia. Activator may not support your version of IOS properly, so make sure to check with others.</ul><p><em>(Jailbreaking discord is a suitable place to ask: <a href="https://discord.gg/bHdzaab"target="_blank"class="url">https://discord.gg/bHdzaab</a>)</em><ul><li>Install Activator from that repo.<li>AutoTouch will automatically detect Activator and use it as the default control method. From there you can set what actions will bring up the AutoTouch control panel.</ul></blockquote><h2 id="scriptRecord">How do I record scripts?</h2><blockquote><ol start=""><li>Bring up the AutoTouch control panel by using your chosen activation method</ol><p><em>Default is to hold the volume down unless you changed it with the Activator tweak.</em> <img src="img/recordExample.png"alt="Control Panel"referrerpolicy="no-referrer"class="Image"><ol start="2"><li>Press the "Record" button to start recording.<li>All touch and key inputs will be recorded into a script.<li>Hold on volume decrease button (or chosen Activator method) again to stop the recording.<li>Then, there will be a Lua script named with create time in the script list. You can edit, rename or play it back.</ol><div class="md-diagram-panel"><svg height="250"version="1.1"width="537.453125"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"style="overflow:hidden;position:relative;top:-.734375px;max-width:100%;height:auto"viewBox="0 0 537.453125 250"><desc style="-webkit-tap-highlight-color:transparent">Created with Raphaël 2.2.0</desc><defs style="-webkit-tap-highlight-color:transparent"><path stroke-linecap="round"d="M5,0 0,2.5 5,5z"id="raphael-marker-block"style="-webkit-tap-highlight-color:transparent"></path><marker id="raphael-marker-endblock55-objdu5p3"markerHeight="5"markerWidth="5"orient="auto"refX="2.5"refY="2.5"style="-webkit-tap-highlight-color:transparent"><use xlink:href="#raphael-marker-block"transform="rotate(180 2.5 2.5) scale(1,1)"stroke-width="1.0000"fill="currentColor"stroke="none"style="-webkit-tap-highlight-color:transparent"></use></marker><marker id="raphael-marker-endblock55-objp0850"markerHeight="5"markerWidth="5"orient="auto"refX="2.5"refY="2.5"style="-webkit-tap-highlight-color:transparent"><use xlink:href="#raphael-marker-block"transform="rotate(180 2.5 2.5) scale(1,1)"stroke-width="1.0000"fill="currentColor"stroke="none"style="-webkit-tap-highlight-color:transparent"></use></marker><marker id="raphael-marker-endblock55-objh5f9y"markerHeight="5"markerWidth="5"orient="auto"refX="2.5"refY="2.5"style="-webkit-tap-highlight-color:transparent"><use xlink:href="#raphael-marker-block"transform="rotate(180 2.5 2.5) scale(1,1)"stroke-width="1.0000"fill="currentColor"stroke="none"style="-webkit-tap-highlight-color:transparent"></use></marker></defs><rect x="10"y="20"width="135.21875"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="20"y="30"width="115.21875"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="77.609375"y="39"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Common state</tspan></text><rect x="10"y="192"width="135.21875"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="20"y="202"width="115.21875"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="77.609375"y="211"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Common state</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M77.609375,58L77.609375,192"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></path><rect x="198.421875"y="20"width="144.8125"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="208.40625"y="30"width="124.8125"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="270.828125"y="39"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Control panel</tspan></text><rect x="198.421875"y="192"width="144.8125"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="208.40625"y="202"width="124.8125"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="270.828125"y="211"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Control panel</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M270.828125,58L270.828125,192"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></path><rect x="400.640625"y="20"width="106.8125"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="410.828125"y="30"width="86.8125"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="454.046875"y="39"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Recording</tspan></text><rect x="400.640625"y="192"width="106.8125"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="410.828125"y="202"width="86.8125"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="454.046875"y="211"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Recording</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M454.046875,58L454.046875,192"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></path><rect x="87.796875"y="74"width="173.21875"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="174.21875"y="83"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Hold volume button</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M77.609375,96C77.609375,96,235.5292517375201,96,265.8332124591243,96"stroke-width="2"marker-end="url(#raphael-marker-endblock55-objdu5p3)"stroke-dasharray="none"style="-webkit-tap-highlight-color:transparent"></path><rect x="280.8125"y="112"width="163.21875"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="362.4375"y="121"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Click on 'Record'</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M270.828125,134C270.828125,134,419.6865448653698,134,449.0511940966244,134"stroke-width="2"marker-end="url(#raphael-marker-endblock55-objp0850)"stroke-dasharray="none"style="-webkit-tap-highlight-color:transparent"></path><rect x="126.59375"y="150"width="278.84375"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="265.828125"y="159"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Hold volume down button again</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M454.046875,172C454.046875,172,127.14508059993386,172,82.61109591359673,172"stroke-width="2"marker-end="url(#raphael-marker-endblock55-objh5f9y)"stroke-dasharray="6,2"style="-webkit-tap-highlight-color:transparent"></path></svg></div><p> </blockquote><h2 id="scriptPlayback">How do I play back scripts?</h2><blockquote><ol start=""><li>Use your chosen activation method to bring up the AutoTouch control panel.<li>Click the script you want to run.<li>The dialog for playback settings will pop up to determine the number of repeats, interval, and speed of the script. This can be bypassed by setting the script to "play directly" within the AutoTouch app itself</ol><video width="300"autoplay=""muted=""playsinline=""loop=""preload="metadata"onerror='this.style.display="none"'><source src="video\Script_Play_example.mp4"></video><p> <ol start="4"><li>Press the "Play" button on play settings dialog to play immediately.<li>If you press the "Hold" button, it will enter the "Ready to play" status, which every time you quick press the volume down button, the script play back once based on the settings you provided it in the previous modal.<li>Hold volume decrease button to forcibly stop the script playback, or quit the "Ready to play" status.</ol><div class="md-diagram-panel"><svg height="402"version="1.1"width="1087.5390625"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"style="overflow:hidden;position:relative;top:-.921875px;zoom:.702504;max-width:100%;height:auto"viewBox="0 0 1087.5390625 402"><desc style="-webkit-tap-highlight-color:transparent">Created with Raphaël 2.2.0</desc><defs style="-webkit-tap-highlight-color:transparent"><marker id="raphael-marker-endblock55-obj5t7nr"markerHeight="5"markerWidth="5"orient="auto"refX="2.5"refY="2.5"style="-webkit-tap-highlight-color:transparent"><use xlink:href="#raphael-marker-block"transform="rotate(180 2.5 2.5) scale(1,1)"stroke-width="1.0000"fill="currentColor"stroke="none"style="-webkit-tap-highlight-color:transparent"></use></marker><marker id="raphael-marker-endblock55-obj9z2zj"markerHeight="5"markerWidth="5"orient="auto"refX="2.5"refY="2.5"style="-webkit-tap-highlight-color:transparent"><use xlink:href="#raphael-marker-block"transform="rotate(180 2.5 2.5) scale(1,1)"stroke-width="1.0000"fill="currentColor"stroke="none"style="-webkit-tap-highlight-color:transparent"></use></marker><marker id="raphael-marker-endblock55-objg91j5"markerHeight="5"markerWidth="5"orient="auto"refX="2.5"refY="2.5"style="-webkit-tap-highlight-color:transparent"><use xlink:href="#raphael-marker-block"transform="rotate(180 2.5 2.5) scale(1,1)"stroke-width="1.0000"fill="currentColor"stroke="none"style="-webkit-tap-highlight-color:transparent"></use></marker><marker id="raphael-marker-endblock55-objs65il"markerHeight="5"markerWidth="5"orient="auto"refX="2.5"refY="2.5"style="-webkit-tap-highlight-color:transparent"><use xlink:href="#raphael-marker-block"transform="rotate(180 2.5 2.5) scale(1,1)"stroke-width="1.0000"fill="currentColor"stroke="none"style="-webkit-tap-highlight-color:transparent"></use></marker><marker id="raphael-marker-endblock55-objirce5"markerHeight="5"markerWidth="5"orient="auto"refX="2.5"refY="2.5"style="-webkit-tap-highlight-color:transparent"><use xlink:href="#raphael-marker-block"transform="rotate(180 2.5 2.5) scale(1,1)"stroke-width="1.0000"fill="currentColor"stroke="none"style="-webkit-tap-highlight-color:transparent"></use></marker><marker id="raphael-marker-endblock55-objb530z"markerHeight="5"markerWidth="5"orient="auto"refX="2.5"refY="2.5"style="-webkit-tap-highlight-color:transparent"><use xlink:href="#raphael-marker-block"transform="rotate(180 2.5 2.5) scale(1,1)"stroke-width="1.0000"fill="currentColor"stroke="none"style="-webkit-tap-highlight-color:transparent"></use></marker><marker id="raphael-marker-endblock55-objp5f72"markerHeight="5"markerWidth="5"orient="auto"refX="2.5"refY="2.5"style="-webkit-tap-highlight-color:transparent"><use xlink:href="#raphael-marker-block"transform="rotate(180 2.5 2.5) scale(1,1)"stroke-width="1.0000"fill="currentColor"stroke="none"style="-webkit-tap-highlight-color:transparent"></use></marker></defs><rect x="10"y="20"width="135.21875"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="20"y="30"width="115.21875"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="77.609375"y="39"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Common state</tspan></text><rect x="10"y="344"width="135.21875"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="20"y="354"width="115.21875"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="77.609375"y="363"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Common state</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M77.609375,58L77.609375,344"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></path><rect x="198.421875"y="20"width="144.8125"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="208.40625"y="30"width="124.8125"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="270.828125"y="39"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Control panel</tspan></text><rect x="198.421875"y="344"width="144.8125"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="208.40625"y="354"width="124.8125"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="270.828125"y="363"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Control panel</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M270.828125,58L270.828125,344"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></path><rect x="439.65625"y="20"width="144.8125"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="449.640625"y="30"width="124.8125"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="512.0625"y="39"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Play settings</tspan></text><rect x="439.65625"y="344"width="144.8125"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="449.640625"y="354"width="124.8125"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="512.0625"y="363"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Play settings</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M512.0625,58L512.0625,344"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></path><rect x="652.0859375"y="20"width="202.421875"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="662.078125"y="30"width="182.421875"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="753.296875"y="39"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Ready to play state</tspan></text><rect x="652.0859375"y="344"width="202.421875"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="662.078125"y="354"width="182.421875"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="753.296875"y="363"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Ready to play state</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M753.296875,58L753.296875,344"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></path><rect x="969.9296875"y="20"width="87.609375"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="980.125"y="30"width="67.609375"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="1013.734375"y="39"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Playing</tspan></text><rect x="969.9296875"y="344"width="87.609375"height="38"rx="0"ry="0"fill="var(--bg-color)"stroke="currentColor"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></rect><rect x="980.125"y="354"width="67.609375"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="1013.734375"y="363"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Playing</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M1013.734375,58L1013.734375,344"stroke-width="2"style="-webkit-tap-highlight-color:transparent"></path><rect x="87.796875"y="74"width="173.21875"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="174.21875"y="83"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Hold volume button</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M77.609375,96C77.609375,96,235.5292517375201,96,265.8332124591243,96"stroke-width="2"marker-end="url(#raphael-marker-endblock55-obj5t7nr)"stroke-dasharray="none"style="-webkit-tap-highlight-color:transparent"></path><rect x="281.015625"y="112"width="221.234375"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="391.4453125"y="121"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Select a script to play</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M270.828125,134C270.828125,134,472.5434526966419,134,507.0655339259744,134"stroke-width="2"marker-end="url(#raphael-marker-endblock55-obj9z2zj)"stroke-dasharray="none"style="-webkit-tap-highlight-color:transparent"></path><rect x="522.25"y="150"width="221.234375"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="632.6796875"y="159"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Click the 'Hold' button</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M512.0625,172C512.0625,172,713.7778276966419,172,748.2999089259744,172"stroke-width="2"marker-end="url(#raphael-marker-endblock55-objg91j5)"stroke-dasharray="none"style="-webkit-tap-highlight-color:transparent"></path><rect x="792.296875"y="188"width="182.828125"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="883.515625"y="197"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Press volume button</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M753.296875,210C753.296875,210,972.6421448253095,210,1008.7355803385562,210"stroke-width="2"marker-end="url(#raphael-marker-endblock55-objs65il)"stroke-dasharray="none"style="-webkit-tap-highlight-color:transparent"></path><rect x="763.484375"y="226"width="240.4375"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="883.515625"y="235"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Press volume button again</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M1013.734375,248C1013.734375,248,794.3891051746905,248,758.2956696614438,248"stroke-width="2"marker-end="url(#raphael-marker-endblock55-objirce5)"stroke-dasharray="6,2"style="-webkit-tap-highlight-color:transparent"></path><rect x="652.46875"y="264"width="221.234375"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="762.8984375"y="273"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Click the "Play" button</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M512.0625,286C512.0625,286,956.4364817244932,286,1008.7285371910962,286"stroke-width="2"marker-end="url(#raphael-marker-endblock55-objb530z)"stroke-dasharray="none"style="-webkit-tap-highlight-color:transparent"></path><rect x="459.25"y="302"width="173.21875"height="18"rx="0"ry="0"fill="none"stroke="none"style="-webkit-tap-highlight-color:transparent"></rect><text x="545.671875"y="311"text-anchor="middle"font-family="Andale Mono, monospace"font-size="16px"stroke="none"fill="currentColor"style="-webkit-tap-highlight-color:transparent;text-anchor:middle;font-family:""><tspan dy="4"style="-webkit-tap-highlight-color:transparent">Hold volume button</tspan></text><path fill="var(--bg-color)"stroke="currentColor"d="M1013.734375,324C1013.734375,324,156.1104972343892,324,82.61782606843963,324"stroke-width="2"marker-end="url(#raphael-marker-endblock55-objp5f72)"stroke-dasharray="6,2"style="-webkit-tap-highlight-color:transparent"></path></svg></div><p> </blockquote><h2 id="playSettings">How do change 'play settings' for scripts?</h2><blockquote><ul><li>You can set an Activator action to trigger a script directly.<li>Additionally you turn on "play directly" to skip the play settings dialog while playing.</ul><p><img src="img\playDirectly.png"alt="Play Directly Panell"referrerpolicy="no-referrer"class="Image"></blockquote><h2 id="screenshots">How do I take screenshots?</h2><blockquote><ol start=""><li>Press “Snap” button on the AutoTouch control panel to take screenshot.<li>The screenshot will be saved as 32-bit BMP image in the 'Screenshots' folder, which can be used to specify parameters of <a href="#getColors">getColors</a>, <a href="#findColors">findColors</a> or <a href="#findImage">findImage</a> and more in your scripts. AutoTouch needs image files to be in this format for most operations.</ol><p>Alternatively you may also use the <a href="#screenshot">screenshots function</a> to capture a screenshot via a script</blockquote><h2 id="scriptWrite">How do I start writing scripts?</h2><blockquote><ul><li>From within the AutoTouch app, press "+" button at the top right, choose “Create a script” to open the script editor.<li>Start writing Lua code!<li>Press "save" button to save the script.</ul><video width="300"autoplay=""loop=""muted=""playsinline=""preload="metadata"onerror='this.style.display="none"'><source src="video\Script_Creation_example.mp4"></video></blockquote><h2 id="funcHelper">How do I use the "Function Helper" while writing scripts?</h2><blockquote><ul><li>There are "Extensions", "Indent" and "Statements" buttons on top of the keyboard in the script editor. You can conveniently insert extended functions, indent or common statement of Lua Language.<li>Press the "Extension" button to be presented with the extended functions list, click a function to insert into the script.<li>Press the "HELPER" button on the function list, it will help you to determine the coordinates, colors or key flags for the functions.</ul></blockquote><div class="row"><div class="column"><figure><img src="img\scrHelp1.PNG"class="ImageBorder"alt="Function Help1"referrerpolicy="no-referrer"style="width:100%"onerror='this.style.display="none"'><figcaption>1 of 4</figcaption></figure></div><div class="column"><figure><img src="img\srcHelp2.PNG"class="ImageBorder"alt="Function Help2"referrerpolicy="no-referrer"style="width:100%"onerror='this.style.display="none"'><figcaption>2 of 4</figcaption></figure></div><div class="column"><figure><img src="img\srcHelp3.PNG"class="ImageBorder"alt="Function Help3"referrerpolicy="no-referrer"style="width:100%"onerror='this.style.display="none"'><figcaption>3 of 4</figcaption></figure></div><div class="column"><figure><img src="img\srcHelp4.PNG"class="ImageBorder"alt="Function Help4"referrerpolicy="no-referrer"style="width:100%"onerror='this.style.display="none"'><figcaption>4 of 4</figcaption></figure></div></div><h2 id="scriptWrite">How do I write and manage scripts on a computer?</h2>s<blockquote><ul><li>Turn on the Web Server in AutoTouch settings and visit the URL that appears just below,on you preferred browser. You can manage scripts remotely from there.<li>You can also turn on WebDAV Server and connect the told address with WebDAV client on computer.</ul></blockquote><h2 id="package">What is a package and how do I use it?</h2><blockquote><ul><li>You can create a package as sort of script project/folder that will contain different scripts, files and images etc. Packages must have a <code>main.lua</code> file which will be run first when executing it through AutoTouch. A package is like a zip file and also support encryption, they are named with <code>.at</code> extension i.e <code>myFirstPackage.at</code>.<li>Package can be encrypted to xxx.ate which is also execuate-able and can be released to Script Store.</ul></blockquote><h2 id="encrypt">How do I encrypt scripts?</h2><blockquote><ol start=""><li>Tap accessory button of a package or script in the local script list, choose "Encrypt".<li>Input the encryption password or leave it blank if you do not want one.<li>Press "Confirm" to complete the encryption. A encrypted file with the same name but ended with .lua.e or .ate will be generated in the script list then.<li>You can play the encrypted scripts, or release them to Script Store.</ol></blockquote><h2 id="store">How do I sell scripts on the store?</h2><blockquote><ol start=""><li>Visit <a href="https://autotouch.net/server/login.php"target="_blank"class="url">https://autotouch.net/server/login.php</a> from browser on computer.<li>Complete the details required to create a new script.<li>Create a detailed description and nice looking mobile suitable html page for the script, a YouTube video embeded within the page is preferred.<li>Upload a encrypted script or package as a new version to this script.<li>Wait for approval.<li>You should setup the Digital Rights Management in the script by yourself, AutoTouch Script Store can not help you with that currently.</ol><p>Note: low-effort/recorded scripts will not be accepted please make sure they add something unique!</blockquote><h2 id="buyScript">How do I download and buy scripts from Script Store?</h2><blockquote><ul><li>You can directly download scripts from the store within the AutoTouch app.<li>You need to contact the author to buy the decryption password. Take care with the transaction,all effort is made to ensure on high quality scripts are uploaded but AutoTouch cannot prevent an author from scamming you, so take care with the payment. Any abuse will lead to a ban from the platform.</ul></blockquote><h2 id="license">How do I buy a AutoTouch license?</h2><blockquote><ol start=""><li>Tap License on AutoTouch settings to enter the license management view.<li>Read the instructions and do be aware that AutoTouch license has a <u><strong>ONE YEAR</strong></u> validity period!<li>It will automatically activate current device after the payment if you use PayPal (If failed just follow the next step).<li>You can query bought licenses with your PayPal ID email, or any activated device SN.<li>You can activate another device with a license after you query it out.<li>You can also "Activate Current Device" diretly with a license key bought from other devices.<li>You should make sure it shows "License Downloaded" at top-right of the License view after it is activated.<li>It allows only one time activation a day, you may do it again after 24 hours if you need.</ol><p><img src="img/license.png"alt="License"referrerpolicy="no-referrer"class="Image"></blockquote><h1 id="scripting">Scripting</h1><h2 id="tuts">References and Tutorials</h2><p>You can learn how to use Lua language from here:《<a href="http://www.lua.org/manual/5.3/">Lua Official Reference Manual</a>》<p>For further reading consider:<ul><li><a href="https://www.lua.org/pil/">Programming in Lua</a> - By purchasing these books your money goes straight to supporting the developers of <a href="https://www.lua.org">Lua</a> and if you purchase the e-book it comes as DRM free<li><a href="http://lua-users.org/wiki/LuaTutorial">Lua-wiki Tutorial</a> - Moderate intro to lua, for people somewhat comfortable with programming concepts already<li><a href="http://luatut.com/crash_course.html">Lua Crash Course</a> - Course that runs through everything at a very fast pace, you wont understand much at first, slightly technical<li><a href="https://www.tutorialspoint.com/lua/">Tutorialspoint - Lua Course</a> - Free, self contained Lua course for beginners, recommended. The content itself is a bit bland due to a lack of colors or pictures but stick with it<li><a href="https://love2d.org/">LÖVE - Lua game engine</a> - LÖVE is an <em>awesome</em> framework you can use to make 2D games in Lua. It's free, open-source, and works on Windows, Mac OS X, Linux, Android and iOS.</ul><h2 id="devTools">Development Tools</h2><p><a href="https://studio.zerobrane.com/">ZeroBrane Studio</a> is a lightweight free/pay what you want open-source Lua IDE with code completion, syntax highlighting, code analyzer, live coding, and debugging support for Lua 5.1, Lua 5.2, Lua 5.3, LuaJIT, and other Lua engines.<blockquote><p>A user created a ZeroBrane plugin that integrates all AutoTouch functions, autocomplete and definitions lookup. Get it <a href="https://github.com/Xamanthas/AT_ZBS-API">here</a></blockquote><hr><p><a href="http://luastudio.net/">LuaStudio</a> is a professional development environment for debugging Lua script in your applications. It's quite fast but is only based on Lua 5.2 whilst AutoTouch now uses Lua 5.3. The site periodically goes down, not recommended.<hr><p><a href="https://plaza.rakuten.co.jp/cocoab/">AutoMainPNG</a> - JP/Eng <em>(English is little hard to understand)</em> paid scripting editor made specifically for AutoTouch. Costs money to unlock further features, pretty great idea for scripting noobs but needs clearer translation.<h2 id="coord">Coordinate, Size and Orientation System</h2><p>AutoTouch uses pixel based Native Resolution as the coordinate and size system. Resolutions of different iOS devices are <a href="https://developer.apple.com/library/archive/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/Displays/Displays.html">here</a> however Apple has not updated it since 2017.<blockquote><p>For example: The screen size of iPhone X is 1125 x 2436.</blockquote><p>Origin point (0, 0) is always at the top left of the <strong>Application Interface</strong>, regardless of the device orientation. This concept is used in these functions:<ul><li><p>Touch emulation:<ul><li>touchDown,touchMove,touchUp,</ul><li><p>Return color values of x, y cordinates:<ul><li>getColor, getColors</ul><li><p>Find specified color values:<ul><li>findColor, findColors</ul><li><p>Find a match to a specified image:<ul><li>findImage, findImage2</ul></ul><p><img src="img\coordinatesExample.jpg"class="image-wide"alt="Cordinates Example"referrerpolicy="no-referrer"><p> <h2 id="extnLib">Extension Libraries</h2><p>AutoTouch has some extension libraries built in, while you can also add these libraries by yourself, just place<code>.so</code> files at <code>/usr/local/lib/lua/5.3</code> and <code>.lua</code> files at <code>/var/mobile/Library/AutoTouch/Library/LuaLibraries</code>.<p><strong>Warning:</strong> <strong>DO NOT</strong> use script filename same as the libraries’ name, such as <code>lcurl</code>, <code>lfs</code>, <code>lsqlite3</code><h3 id="curl">Lua-cURL</h3><p>cURL is a command-line tool for getting or sending data including files using <a href="https://en.wikipedia.org/wiki/URL">URL</a> syntax. It supports communicating with HTTP, HTTPS, FTPS, and many, many <a href="https://curl.haxx.se/">more</a>.<p>AT implements Lua-cURL V3 for cURL support.<p><a href="https://lua-curl.github.io/lcurl/modules/cURL.html">Documentation</a><p><a href="https://github.com/Lua-cURL/Lua-cURLv3">Github project</a><p><code>Examples</code><pre><code class="language-lua"lang="lua">-- HTTP Get
local curl = require('lcurl')
curl.easy{
url = 'http://httpbin.org/get',
httpheader = {
"X-Test-Header1: Header-Data1",
"X-Test-Header2: Header-Data2",
},
writefunction = alert -- use io.stderr:write()
}
:perform()
:close()
-- HTTP Post
curl.easy()
:setopt_url('http://posttestserver.com/post.php')
:setopt_writefunction(io.write)
:setopt_httppost(curl.form() -- Lua-cURL guarantee that form will be alive
:add_content("test_content", "some data", {
"MyHeader: SomeValue"
})
:add_buffer("test_file", "filename", "text data", "text/plain", {
"Description: my file description"
})
:add_file("test_file2", "BuildLog.htm", "application/octet-stream", {
"Description: my file description"
})
)
:perform()
:close()
</code></pre><h3 id="luaSocket">LuaSocket</h3><p>LuaSocket is a Lua extension library which supported <a href="http://w3.impa.br/~diego/software/luasocket/introduction.html#tcp">TCP</a>, <a href="http://w3.impa.br/~diego/software/luasocket/introduction.html#udp">UDP</a>, <a href="http://w3.impa.br/~diego/software/luasocket/smtp.html">SMTP</a>, <a href="http://w3.impa.br/~diego/software/luasocket/http.html">HTTP</a>, <a href="http://w3.impa.br/~diego/software/luasocket/ftp.html">FTP</a> protocols. Learn how to use it from here](<a href="http://w3.impa.br/~diego/software/luasocket/introduction.html"target="_blank"class="url">http://w3.impa.br/~diego/software/luasocket/introduction.html</a>).<h3 id="luaSec">LuaSec</h3><p>LuaSec is a binding for OpenSSL library to provide TLS/SSL communication. It takes an already established TCP connection and creates a secure session between the peers. <a href="https://github.com/brunoos/luasec/wiki">Learn More</a><h3 id="luaSqlite3">LuaSqlite3</h3><p>LuaSQLite 3 is a thin wrapper around the public domain SQLite3 database engine. <a href="http://lua.sqlite.org/index.cgi/doc/tip/doc/lsqlite3.wiki">Learn More</a><p><code>Examples</code><pre><code class="language-sqlite"lang="sqlite">local sqlite3 = require("lsqlite3")
local db = sqlite3.open_memory()
db:exec[[
CREATE TABLE test (id INTEGER PRIMARY KEY, content);
INSERT INTO test VALUES (NULL, 'Hello World');
INSERT INTO test VALUES (NULL, 'Hello Lua');
INSERT INTO test VALUES (NULL, 'Hello Sqlite3')
]]
for row in db:nrows("SELECT * FROM test") do
log(row.content)
end
</code></pre><h3 id="luaFS">LuaFileSystem</h3><p>LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution. It offers a portable way to access the underlying directory structure and file attributes.<a href="https://keplerproject.github.io/luafilesystem/manual.html">Learn More</a><h2 id="extnFunc">Extension Functions</h2><p>Extension functions are used to extend Lua language. With these the device can simulate most human inputs and also achieve automation. Some of these are: screenshot, color searching, color matching, and picture matching.<h3 id="touchDown">touchDown(id, x, y)</h3><pre class="description"><code>Presses a coordinate (x,y) on the screen.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>id<td style="text-align:center">Integer<td>Finger ID. Used to mark a finger in single-touch or multi-touch.<tr><td>x<td style="text-align:center">Float<td>x-coordinate on the screen<tr><td>y<td style="text-align:center">Float<td>y-coordinate on the screen</table></figure><p><code>Return</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">-- Press by one finger at coordinate (100,200).
touchDown(0, 100, 200);
-- Press by three fingers at three locations on the screen.
touchDown(0, 100, 200);
touchDown(1, 200, 300);
touchDown(2, 300, 400);
-- Implement a tap function
function tap(x, y)
touchDown(0, x, y);
usleep(16000);
touchUp(0, x, y);
end
-- Tap at (100, 200)
tap(100, 200);
</code></pre><h3 id="touchUp">touchUp(id, x, y)</h3><pre class="description"><code>Lift the finger from coordinate (x,y)
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>id<td style="text-align:center">Integer<td>Finger ID. Used to mark a finger in single-touch or multi-touch.<tr><td>x<td style="text-align:center">Float<td>x-coordinate on the screen<tr><td>y<td style="text-align:center">Float<td>y-coordinate on the screen</table></figure><p><code>Return</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">-- Click the screen with one finger at coordinate (100,200).
touchDown(0, 100, 200);
usleep(16000);
touchUp(0, 100, 200);
-- Press by three fingers at three locations on the screen, move to new location, and then lift the finger.
touchDown(0, 100, 200);
touchDown(1, 200, 300);
touchDown(2, 300, 400);
usleep(16000);
touchMove(0, 150, 250);
touchMove(1, 250, 350);
touchMove(2, 350, 450);
usleep(16000);
touchUp(0, 150, 250);
touchUp(1, 250, 350);
touchUp(2, 350, 450);
</code></pre><h3 id="tap">tap(x, y)</h3><p><code>Taps with a single finger on the specified coordinate.</code><p><code>Parameters</code><figure><table><thead><tr><th style="text-align:left">Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td style="text-align:left">x<td style="text-align:center">Float<td>x-coordinate on the screen<tr><td style="text-align:left">y<td style="text-align:center">Float<td>y-coordinate on the screen</table></figure><p><code>Return</code> None<p><code>Note:</code> Tap has far less control due to its simplicity and has no built in randomness. It is recommended to overwrite tap when used in games as it easily detected as the length of the 'finger press' will always be the same <code>Examples</code><pre><code class="language-lua"lang="lua">--Example 1: Quickly taps once on the screen
tap(300, 435);
usleep(20000);
--Example 2: Uses findColors (discussed later) to look for a particular app icon on the home screen, logs it then taps the resulting co-ordinates. These sorts of cases are where its okay to use the unmodified tap function. In games its too easy to detect
local result = findColors({{3380451,0,0}, {16777215,1,0}, {9160301,6,0}, {3380451,-2,0}, {14133291,6,45}, {16764976,8,49}, {14556453,35,82}, {228316,-7,76}}, 0, nil);;
for i, v in pairs(result) do
log(string.format("Found the app at: x:%f, y:%f", v[1], v[2]));
log(getColor(v[1], v[2]));
tap(v[1], v[2]);
end
</code></pre><h3 id="touchMove">touchMove(id, x, y)</h3><pre class="description"><code>Move the finger to coordinate (x,y).
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>id<td style="text-align:center">Integer<td>Finger ID. is used to mark a finger in single-touch or multi-touch.<tr><td>x<td style="text-align:center">Float<td>x-coordinate on the screen<tr><td>y<td style="text-align:center">Float<td>y-coordinate on the screen</table></figure><p><code>Return</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">-- Press one finger at coordinate (100,200) and move the finger to coordinate (200,200).
touchDown(0, 100, 200);
usleep(16000);
touchMove(0, 200, 200);
-- Press three fingers at three locations on the screen and move to new location.
touchDown(0, 100, 200);
touchDown(1, 200, 300);
touchDown(2, 300, 400);
usleep(16000);
touchMove(0, 150, 250);
touchMove(1, 250, 350);
touchMove(2, 350, 450);
</code></pre><h3 id="keyDown">keyDown(keyType)</h3><pre class="description"><code>Simulate the pressing of physical key.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>keyType<td style="text-align:center">Integer<td>Physical key identification. Now you can use <a href="#header-undefined">these physical keys</a>.</table></figure><p><code>Return</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">-- Simulate the pressing of Home Key.
keyDown(KEY_TYPE.HOME_BUTTON);
-- How do i simulate a key pressing?
function keyPress(keyType)
keyDown(keyType);
usleep(10000);
keyDown(keyUp);
end
keyPress(KEY_TYPE.HOME_BUTTON);
-- How to simulate a screen lock function?
function lockScreen()
keyDown(KEY_TYPE.POWER_BUTTON);
keyUp(KEY_TYPE.POWER_BUTTON);
end
</code></pre><h3 id="keyUp">keyUp(keyType)</h3><pre class="description"><code>Simulate the lifting of physical key.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>keyType<td style="text-align:center">Integer<td>Physical key identification. Now you can use <a href="#header-undefined">these physical keys</a>.</table></figure><p><code>Return</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">-- Simulate the action of pressing and lifting Home Key.
keyDown(KEY_TYPE.HOME_BUTTON);
usleep(10000);
keyUp(KEY_TYPE.HOME_BUTTON);
</code></pre><h3 id="getColor">getColor(x, y)</h3><pre class="description"><code>Get the color value of the pixel point at the specified coordinate.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>x<td style="text-align:center">Float<td>x-coordinate on the screen<tr><td>y<td style="text-align:center">Float<td>y-coordinate on the screen</table></figure><p><code>Return</code><figure><table><thead><tr><th>Return<th style="text-align:center">Type<th>Specification<tbody><tr><td>color<td style="text-align:center">Integer<td>Integer color value of the pixel point</table></figure><p><code>Examples</code><pre><code class="language-lua"lang="lua">local color = getColor(100, 200);
alert(string.format("Pixel color is :%d", color));
-- Pop up color: 16777215
</code></pre><h3 id="getColors">getColors(locations)</h3><pre class="description"><code>Get the color values of the pixel points of the specified coordinates on current screen.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>locations<td style="text-align:center">table<td>A group of coordinates specifying the points you want to return the color from i.e {{x1,y1},{x2,y2},{x3,y4}}</table></figure><p><code>Return</code><figure><table><thead><tr><th>Return<th style="text-align:center">Type<th>Specification<tbody><tr><td>colors<td style="text-align:center">table<td>Colors found are returned in their corresponding order.</table></figure><p><code>Examples</code><pre><code class="language-lua"lang="lua">local result = getColors({{100, 200}, {200, 300}, {300, 400}});
for i, v in pairs(result) do
log(string.format("Gotten color:%d", v));
end
</code></pre><h3 id="findColor">findColor(color, count, region)</h3><pre class="description"><code>Search the coordinates of the pixel points matching the specified color on current screen.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>color<td style="text-align:center">Integer<td>Matched color value.<tr><td>count<td style="text-align:center">Integer<td>The number refers to how many matched pixel points is required for a match. 0 is default setting, which requires all points match (slowest option). 1 refers to only the first matching pixel point is found. 2 refers to only the first two pixel points are found. The lower the number is (above zero), the faster the speed is.<tr><td>region<td style="text-align:center">table<td>You only search the result in the specified area. This area is the table type including four values {x, y, width, height}. The four values respectively represent the coordinate x, coordinate y, width, and height of the rectangular area. {100,100,200,200} is an example. If you do not want to specify the area, just input nil.</table></figure><p><code>Return values</code><figure><table><thead><tr><th>Return value<th style="text-align:center">Type<th>Specification<tbody><tr><td>locations<td style="text-align:center">table<td>Coordinates of matched pixel points. For example: {{x1, y1}, {x2, y2}, ...}</table></figure><p><code>Example</code><pre><code class="language-lua"lang="lua">-- Example 1:
local result = findColor(0x0000ff, 2, nil);
for i, v in pairs(result) do
log(string.format("Found pixel: x:%f, y:%f", v[1], v[2]));
end
-- Example 2:
local result = findColor(0x00ddff, 0, {100, 50, 200, 200});
for i, v in pairs(result) do
log(string.format("Found pixel: x:%f, y:%f", v[1], v[2]));
end
-- Example 3:
local region = {100, 50, 200, 200};
local result = findColor(0x00ddff, 0, region);
for i, v in pairs(result) do
log(string.format("Found pixel: x:%f, y:%f", v[1], v[2]));
end
</code></pre><p><code>Internal Implementation</code><pre><code class="language-lua"lang="lua">function findColor(color, count, region)
return findColors({{color,0,0}}, count, region);
end
</code></pre><h3 id="findColors">findColors(colors, count, region)</h3><p>Searches a region for specified colors and their position relative to the other colors matches. If a match is found it returns the coordinate of the matching first color.<p>This function has the search efficiency far beyond findImage. For example, you do not need to match the whole picture, only the anchor colors and their corresponding location.<p>You can specify the number of the results by count parameter. 0 refers to all, 1 refers to the first one, and 2 refers to the first tow. region parameter can specify the search area, which is the table type {x,y,width, height}. You only input nil if no data is specified. The more points you specify to match, the higher the accuracy.<p>This function can use the 'HELPER' tool in the 'Extension' menu. Select the anchors’ colors in a selected bmp and the tool will supply the corresponding location and color to the function’s parameter automatically.<p>In the below image, the table highlighted is the coordinate that will be returned upon a match.<p><img src="img\findColorsExample.png"alt="Find Colors Example"referrerpolicy="no-referrer"><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>colors<td style="text-align:center">table<td>Include color and their corresponding location, such as: <code>{{0x00ddff,0,0}, {0x00eeff,10,10}, {0x0000ff,0,20}}</code>. The inner tables includes 3 separate values: the 1st is the color value, the 2nd and 3rd are the x & y coordinates respectively. The corresponding location of the first color’s table is always (0,0) due to it being the origin point from which other coordinates are calculated. <code>{0x00ddff,0,0}</code> is an example. The anchor points are calculated relative to the first point.<tr><td>count<td style="text-align:center">Integer<td>The number refers to how many matched pixel points are required to be found before a match is declared. 0 is default setting, which requires all matching points to be found. 1 requires only 1 matching point to be found and so forth. The lower the count (above zero), the faster the script will resolve.<tr><td>region<td style="text-align:center">table<td>Specify the search region. This area is the table type that includes four values {x, y, width, height}. The four values represent the coordinate x, coordinate y, width, and height of the rectangular area. If you do not want to specify the area, just input <code>nil</code>.</table></figure><p><code>Return values</code><figure><table><thead><tr><th>Return value<th style="text-align:center">Type<th>Specification<tbody><tr><td>locations<td style="text-align:center">table<td>The coordinate of the first color matched in the found rectangular area, including {{x1, y1}, {x2, y2}, ...}</table></figure><p><code>Examples</code><pre><code class="language-lua"lang="lua">-- Example 1:
local result = findColors({{0x00ddff,0,0}, {0x00eeff,10,10}, {0x0000ff,0,20}}, 2, nil);
for i, v in pairs(result) do
log(string.format("Found rect at: x:%f, y:%f", v[1], v[2]));
end
-- Example 2:
local colors = {{0x00ddff,0,0}, {0x00eeff,10,10}, {0x0000ff,0,20}};
local result = findColors(colors, 0, nil);
for i, v in pairs(result) do
log(string.format("Found rect at: x:%f, y:%f", v[1], v[2]));
end
-- Example 3:
local colors = {{0x00ddff,0,0}, {0x00eeff,10,10}, {0x0000ff,0,20}};
local region = {100, 50, 200, 200};
local result = findColors(colors, 0, region);
for i, v in pairs(result) do
log(string.format("Found match at: x:%f, y:%f", v[1], v[2]));
tap(v[1], v[2]);
end
</code></pre><h3 id="findImage">findImage(imagePath, count, fuzzy, ignoreColors, region, debug)</h3><pre class="description"><code>Searches the region specified for a match with the provided image and if a match is found returns the coordinate of the top left corner of the matched image
</code></pre><p><img src="img\findImage.jpg"alt="Find Image Example"referrerpolicy="no-referrer"><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<th style="text-align:center">Optional<th style="text-align:center">Default<tbody><tr><td>targetImagePath<td style="text-align:center">String<td>Relative path of the target image to match, for example: “Screenshots/gold.PNG”. Any valid format of images are supported.<td style="text-align:center">NO<td style="text-align:center"> <tr><td>count<td style="text-align:center">integer<td>How many matches of the given image you would like to find on-screen. Pass nil if you just want to use the default value.<td style="text-align:center">YES<td style="text-align:center">1<tr><td>threshold<td style="text-align:center">float<td>Searching precision, maximum value is 1 means every anchor point must match exactly, minimum value is 0.2 default is 0.9, usually 0.99 is good. Pass nil if you just want to use the default value.<td style="text-align:center">YES<td style="text-align:center">0.9<tr><td>region<td style="text-align:center">table<td>You only search the result in the specified area. This area is the table type including four values {x, y, width, height}. The four values respectively represent the coordinate x, coordinate y, width, and height of the rectangular area. Pass nil if you just want to use the default value<td style="text-align:center">YES<td style="text-align:center">Whole screen<tr><td>debug<td style="text-align:center">boolean<td>If pass debug=true, it will produce a image ends with “-Debug.PNG” in same directory as the target image is, marked with matched areas.<td style="text-align:center">YES<td style="text-align:center">false</table></figure><p><code>Return values</code><figure><table><thead><tr><th>Return value<th style="text-align:center">Type<th>Specification<tbody><tr><td>locations<td style="text-align:center">table<td>The array at the coordinate on the center of the matched area(s): {{x1, y1}, {x2, y2}, ...}</table></figure><p><code>Examples</code><pre><code class="language-lua"lang="lua">-- Example 1:
local result = findImage("Screenshots/Gold.PNG", 5, 0.99, nil, true)
for i, v in pairs(result) do
log(string.format("Found rect at: x:%f, y:%f", v[1], v[2]));
end
-- Example 2:
local result = findImage("Screenshots/Gold.PNG", nil, nil, nil, true)
for i, v in pairs(result) do
log(string.format("Found rect at: x:%f, y:%f", v[1], v[2]));
end
-- Example 3:
local result = findImage("Screenshots/Gold.PNG", 3)
for i, v in pairs(result) do
log(string.format("Found rect at: x:%f, y:%f", v[1], v[2]));
end
-- Example 4:
local imagePath = "images/spirit.PNG";
local region = {100, 100, 300, 300};
local result = findImage(imagePath, 2, 0.98, region, true)
for i, v in pairs(result) do
local x = v[1], y = v[2];
log(string.format("Found rect at: x:%f, y:%f", x, y));
-- Click the found location once.
tap(x, y);
usleep(16000);
end
</code></pre><h3 id="findImage2">findImage2(targetImagePath, targetsToFind)</h3><p><code>Searches the entire screen for a match to the specified image, it is able to deal with most image size, orientation and color changes intelligently.</code><p>FindImage2 is a powerful successor to findImage allowing you to search for matches in very dynamic applications and games. However these features do come with a performance hit, in most cases it <em>will</em> be slower, so you should take care and only use when the powerful features are needed<p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>imagePath<td style="text-align:center">String<td>The path of the picture, only the subfolders need to be specified if it sits somewhere within the AutoTouch directory. For example, <code>images/script.bmp</code> means <code>/var/mobile/Library/AutoTouch/Scripts/images/spirit.bmp</code>. You need not input the complete path.<br>Accepts <strong>only</strong> 32-bit <code>.bmp</code> & <code>.png</code><tr><td>targetsToFind (optional)<td style="text-align:center">Integer<td>findImage2 handles matching differently. It will only determine a proper match, there is no 'fuzziness'. As such a new parameter called <code>targetsToFind</code> controls how many proper matches you want to return. For example: If there are 5 identical footballs on the screen, with the same image provided to the path and you have set <code>targetsToFind</code>= 5, then the function will return the coordinates of the 5 matches</table></figure><p><code>Return values</code><figure><table><thead><tr><th>Return value<th style="text-align:center">Type<th>Specification<tbody><tr><td>locations<td style="text-align:center">table<td>The array will be at the center of the matching area: {{x1, y1}, {x2, y2}, ...}</table></figure><h3 id="screenshot">screenshot(filePath, region)</h3><pre><code>Take a screenshot for the whole screen or specified area and save as 32-bit BMP format at specified file path.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>filePath<td style="text-align:center">string<td>The path of screenshot. From AutoTouch v3.1.1, you only input the location subordinated to AutoTouch file directory, namely, the path of “Local Script”. (you can get the path of the file directory by rootDir function). For example, “images/script.bmp” means “/var/mobile/Library/AutoTouch/Scripts/images/spirit.bmp”. You need not input the complete path.<tr><td>region<td style="text-align:center">table<td>Define the region to take the screenshot with. This area is a table type including four values {x, y, width, height}. {100,100,200,200} is an example. If you do not want to specify the area, just input nil.</table></figure><p><code>Return values</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">-- Take a screenshot of the whole screen and save in the specified location.
screenshot ("images/screenshot1.bmp", nil);
-- Take a screenshot of the specified area and save.
screenshot ("images/screenshot2.bmp", {100, 100, 200, 200});
</code></pre><h3 id="appRun">appRun(appIdentifier)</h3><pre class="description"><code>Run specified application.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>appIdentifier<td style="text-align:center">string<td>Application identifier, including "com.apple.mobilesafari".</table></figure><p><code>Return values</code> None<p><code>Example</code><pre><code class="language-lua"lang="lua">-- Run Safari
appRun("com.apple.mobilesafari");
</code></pre><h3 id="appRun">appKill(appIdentifier)</h3><pre class="description"><code>Kills the specified application.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>appIdentifier<td style="text-align:center">string<td>Application identifier, including "com.apple.mobilesafari".</table></figure><p><code>Return values</code> None<p><code>Example</code><pre><code class="language-lua"lang="lua">-- Kill running Safari app
appKill("com.apple.mobilesafari");
</code></pre><h3 id="appState">appState(appIdentifier)</h3><pre class="description"><code>Get the running state of the specified application
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>appIdentifier<td style="text-align:center">string<td>Application identifier, including "com.apple.mobilesafari".</table></figure><p><code>Return values</code><figure><table><thead><tr><th>Return value<th style="text-align:center">Type<th>Specification<tbody><tr><td>state<td style="text-align:center">string<td>State of Character string type: "NOT RUNNING", "ACTIVATED", "DEACTIVATED"。</table></figure><p><code>Example</code><pre><code class="language-lua"lang="lua">-- Get the state of Safari.
local state = appState("com.apple.mobilesafari");
alert(string.format("State of Safari: %s", state));
-- Pop up the state of Safari: "ACTIVATED"
</code></pre><h3 id="rootDir">rootDir()</h3><pre><code>Get the default directory address of the saved script. This is the default saving address of scripts and screenshots: "/var/mobile/Library/AutoTouch/Scripts/".
</code></pre><p><code>Parameters</code> None<p><code>Return values</code><figure><table><thead><tr><th>Return value<th style="text-align:center">Type<th>Specification<tbody><tr><td>dir<td style="text-align:center">string<td>Default directory address of the saved script.</table></figure><p><code>Examples</code><pre><code class="language-lua"lang="lua">local dirPath = rootDir();
alert(dirPath);
-- Popup "/var/mobile/Library/AutoTouch/Scripts/"
</code></pre><h3 id="usleep">usleep(microseconds)</h3><pre><code>Sleep several microseconds (1/1000000)
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>microseconds<td style="text-align:center">Integer<td>The number of paused microseconds.</table></figure><p><code>Return values</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">-- Sleep 1 second.
usleep(1000000);
</code></pre><h3 id="log">log(content)</h3><pre class="description"><code>Record log, can be seen in the log interface.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>content<td style="text-align:center">string<td>The log content to be recorded.</table></figure><p><code>Return values</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">--Example 1:
log("play here...");
--Example 2: Formats dynamic data passed by functions into a string AutoTouch can log
log(string.format("Log test: x:%f, y:%f", v[1], v[2]));
</code></pre><h3 id="alert">alert(message)</h3><pre><code>Pop up the dialog box, that a user must manually dismiss by clicking "ok"
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>message<td style="text-align:center">string<td>Content to be showed.</table></figure><p><code>Return values</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">alert("Hello World!");
</code></pre><h3 id="toast">toast(message, delay)</h3><pre class="description"><code>Show messages with the toast style. Suitable for when you need no interruptions and dont want to have to manually dismiss the message
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>message<td style="text-align:center">string<td>Content to be showed.<tr><td>delay<td style="text-align:center">integer<td>How long time to keep showing, default is 2 seconds.</table></figure><p><code>Return values</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">toast("Hello I'm a toast!", 5); -- Show message for 5 seconds.
toast("Hello again!"); -- Show message for 2 seconds.
</code></pre><h3 id="vibrate">vibrate()</h3><pre class="description"><code>Vibrate once.
</code></pre><p><code>Parameters</code> None<p><code>Return values</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">-- Vibrate once.
vibrate();
</code></pre><h3 id="playAudio">playAudio(audioFile, times)</h3><pre class="description"><code>Play audio document at specified location. Known to supports .mp3, .mp4 and .caf , probably supports more.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>audioFile<td style="text-align:center">string<td>Absolute path of audio document.<tr><td>times<td style="text-align:center">integer<td>Number of repeated plays. 0 represents infinite repeat.</table></figure><p><code>Return values</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">-- Play audio infinitely.
playAudio("/var/audio.mp3", 0);
</code></pre><h3 id="stopAudio">stopAudio()</h3><pre class="description"><code>Stop playing audio.
</code></pre><p><code>Parameters</code> None<p><code>Return values</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">-- Stop playing audio.
stopAudio();
</code></pre><h3 id="getOrientation">getOrientation()</h3><pre><code>Gets orientation of the screen. Return the integer value. Please refer to the “Orientation Type of Screen” for specific correspondence relation.
</code></pre><p><code>Parameters</code> None<p><code>Return values</code><figure><table><thead><tr><th>Return value<th style="text-align:center">Type<th>Specification<tbody><tr><td>orientation<td style="text-align:center">Integer<td>Screen orientation may be <a href="#header-undefined">these values</a></table></figure><p><code>Examples</code><pre><code class="language-lua"lang="lua">local o = getOrientation();
alert(string.format("Screen orientation is : %d", 0))
-- Pop up the orientation 2 of the screen, and mark the reversed screen.
</code></pre><h3 id="getScreenResolution">getScreenResolution()</h3><pre class="description"><code>Gets the current devices screen resolution.
</code></pre><p><code>Parameters</code> None<p><code>Return values</code><figure><table><thead><tr><th>Return value<th style="text-align:center">Type<th>Specification<tbody><tr><td>width<td style="text-align:center">Integer<td>Width of screen resolution.<tr><td>height<td style="text-align:center">Integer<td>Height of screen resolution.</table></figure><p><code>Examples</code><pre><code class="language-lua"lang="lua">local w, h = getScreenResolution();
alert(string.format("Resolution of iPhone 6 Plus: width:%d, height:%d", w, h));
-- iPhone 6 Plus’s resolution width is 1242 and resolution height is 2208.
</code></pre><h3 id="getSN">getSN()</h3><pre class="description"><code> Get Serial Number of the device.
</code></pre><p><code>Parameters</code> None<p><code>Return values</code><figure><table><thead><tr><th>Return value<th style="text-align:center">Type<th>Specification<tbody><tr><td>SN<td style="text-align:center">string<td>Serial Number of the device.</table></figure><p><code>Examples</code><pre><code class="language-lua"lang="lua">local sn = getSN();
alert(string.format("SN is : %s", sn));
-- Popup shows the SN of the device: C15NFK32TWD2
</code></pre><h3 id="getVersion">getVersion()</h3><pre class="description"><code>Get version of AutoTouch.
</code></pre><p><code>Parameters</code> None<p><code>Return values</code><figure><table><thead><tr><th>Return value<th style="text-align:center">Type<th>Specification<tbody><tr><td>version<td style="text-align:center">string<td>Version of AutoTouch.</table></figure><p><code>Examples</code><pre><code class="language-lua"lang="lua">local version = getVersion();
alert(string.format("Current version of AutoTouch is : %s", version));
-- Pop up shows current version of AutoTouch: 3.5.3-4
</code></pre><h3 id="intToRgb">intToRgb(intColor)</h3><pre class="description"><code>Transit integer color to independent values of R,G,B.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>intColor<td style="text-align:center">Integer<td>Integer color value</table></figure><p><code>Return values</code><figure><table><thead><tr><th>Return value<th style="text-align:center">Type<th>Specification<tbody><tr><td>R<td style="text-align:center">Integer<td>Red color value.<tr><td>G<td style="text-align:center">Integer<td>Green color value.<tr><td>B<td style="text-align:center">Integer<td>Blue color value.</table></figure><p><code>Examples</code><pre><code class="language-lua"lang="lua">local r, g, b = intToRgb(0x2b2b2b);
alert(string.format("R:%d, G:%d, B:%d", r, g, b));
</code></pre><h3 id="rgbToInt">rgbToInt(r, g, b)</h3><pre class="description"><code>Transit values of R,G,B to integer color value.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>R<td style="text-align:center">Integer<td>Red color value.<tr><td>G<td style="text-align:center">Integer<td>Green color value.<tr><td>B<td style="text-align:center">Integer<td>Blue color value.</table></figure><p><code>Return values</code><figure><table><thead><tr><th>Return value<th style="text-align:center">Type<th>Specification<tbody><tr><td>intColor<td style="text-align:center">Integer<td>Integer color value</table></figure><p><code>Examples</code><pre><code class="language-lua"lang="lua">local intColor = rgbToInt(200, 255, 100);
alert(string.format("Int type color: %d", intColor));
</code></pre><h3 id="copyText">copyText(text)</h3><pre class="description"><code>Copy specified text to clipboard.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>text<td style="text-align:center">string<td>Text to be copied.</table></figure><p><code>Return values</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">copyText("This is a copied text!");
</code></pre><h3 id="clipText">clipText()</h3><pre class="description"><code>Get the text in the clipboard.
</code></pre><p><code>Parameters</code> None<p><code>Return values</code><figure><table><thead><tr><th>Return value<th style="text-align:center">Type<th>Specification<tbody><tr><td>text<td style="text-align:center">string<td>Text copied in the clipboard.</table></figure><p><code>Examples</code><pre><code class="language-lua"lang="lua">local text = clipText();
alert(text);
-- Popup shows the text to be copied: "This is a copied text!";
</code></pre><h3 id="inputText">inputText(text)</h3><pre><code>Pastes text to the input box selected now. You can delete a character backspace by inputText("\b").
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>text<td style="text-align:center">string<td>Text to be input.</table></figure><p><code>Return values</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">inputText("Let's input some text automatically without tapping the keyboard!");
-- Delete 3 character by inputing 3 backspaces.
inputText("\b\b\b");
</code></pre><h3 id="dialog">dialog(controls, enableRemember)</h3><pre><code>Pop up self-defined dialog box to accept the user input. Please refer to the example for specific usage.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>controls<td style="text-align:center">table<td>Array of self-defined controls. You can now use <a href="#header-undefined">these dialog box controls</a><tr><td>enableRemember<td style="text-align:center">boolean<td>Whether to use the "remember user's input" function.</table></figure><p><code>Return values</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">--Dialog example
--Plain text label, used for the overall title of the dialog
local label = {type=CONTROLLER_TYPE.LABEL, text="AutoTouch Dialog Example"}
--Switch picker with the title as "Use skill combo?"
local developer2 = {type=CONTROLLER_TYPE.SWITCH, title="Use skill combo?", key="Skillcombo", value=0}
local unitPicker = {type=CONTROLLER_TYPE.PICKER, title="Unit", key="Unit", value="Unit1", options={"Unit1", "Unit3", "Unit3", "Unit4"}}
local collectLootSwitch = {type=CONTROLLER_TYPE.SWITCH, title="Collect loot", key="ADeveloper", value=1}
--Defines what to pass to the controls function, if not described here it will not appear
local controls = {label, developer2, unitPicker, collectLootSwitch}
local enableRemember = true;
-- Pop up the dialog box. After the popup, the script will suspend for user input until the user click “confirm” or “cancel”.
dialog(controls, enableRemember);
-- Then get the input value of user.
alert(string.format("Use skillcombo:%s, Unit choice:%s, Collect loot?:%d", developer2.value, unitPicker.value, collectLootSwitch.value))
</code></pre><p><img src="C:\Users\Joshua\repos\AutoTouchDocuments\img\dialogExample.png"alt="3.png-115.9kB"referrerpolicy="no-referrer"><h3 id="clearDialogValues">clearDialogValues(script)</h3><pre class="description"><code>Clear the remembered values of the dialog created by the function dialog.
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>script<td style="text-align:center">string<td>script path. eg. there is a dialog.lua script in the scripts list, use it like this: clearDialogValues("dialog.lua");</table></figure><p><code>Return values</code> None<p><code>Examples</code><pre><code class="language-lua"lang="lua">-- There is a dialog.lua script in the scripts list
clearDialogValues("dialog.lua");
</code></pre><h3 id="openURL">openURL(urlString)</h3><p>Open url, or open other apps’ url scheme. Look at this <a href="https://ios.gadgethacks.com/news/always-updated-list-ios-app-url-scheme-names-0184033/">iOS App URL Scheme Names</a> and example: <a href="https://developers.google.com/maps/documentation/urls/ios-urlscheme">Google Maps URL Scheme for iOS</a><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th style="text-align:center">Type<th>Specification<tbody><tr><td>urlString<td style="text-align:center">string<td>Target to open.</table></figure><p><code>Return</code><p>None<pre><code class="language-lua"lang="lua">Examples
openURL("https://autotouch.net")
openURL("prefs:root=General&path=About")
openURL("musics://")
openURL("itms-apps://itunes.apple.com")
openURL("tel://+1123456")
openURL("clashofclans://")
</code></pre><h3 id="license">isLicensed()</h3><p>Check if the current device is running licensed AutoTouch<p><code>Parameters</code><p>None<p><code>Return</code><figure><table><thead><tr><th>Return<th style="text-align:center">Type<th>Specification<tbody><tr><td>license status<td style="text-align:center">boolean<td>If current device is licensed it will return true else will return false</table></figure><pre><code class="language-lua"lang="lua">Examples
if isLicensed() then
alert("Your device is licensed by AutoTouch!");
end
</code></pre><h2 id="api">HTTP APIs</h2><p>Commands for controlling AutoTouch over Local Area Network (LAN), they use the same APIs as the <code>Web Server</code> that you can activate in AutoTouch Settings uses.<h3 id="playScript">Play a script</h3><pre><code>GET /control/start_playing?path=/scriptPath
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th>Specification<tbody><tr><td>path<td>Script path.</table></figure><p><code>Return</code><p>Successful:<pre><code class="language-json"lang="json">{
"status": "success"
}
</code></pre><p>Failed:<pre><code class="language-json"lang="json">{
"status": "fail",
"info": ""
}
</code></pre><p>Examples:<pre><code class="language-json"lang="json">HTTP GET http://192.168.1.99:8080/control/start_playing?path=/scriptPath
{
"status": "fail",
"info": "Script doesn't exist."
}
</code></pre><p> <h3 id="stopScript">Stop playing a script</h3><pre><code>GET /control/stop_playing?path=/scriptPath
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th>Specification<tbody><tr><td>path<td>Script path.</table></figure><p><code>Return</code><p>Successful:<pre><code class="language-json"lang="json">{
"status": "success"
}
</code></pre><p>Failed:<pre><code class="language-json"lang="json">{
"status": "fail",
"info": ""
}
</code></pre><p><code>Example</code><pre><code class="language-json"lang="json">HTTP GET http://192.168.1.99:8080/control/start_playing?path=/scriptPath
{
"status": "fail",
"info": "Script doesn't exist."
}
</code></pre><h3 id="listDir">List files in Directory</h3><pre><code>GET /files?path=/Records
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th>Specification<tbody><tr><td>path<td>Directory path to list.</table></figure><p><code>Return</code><pre><code class="language-json"lang="json">{
"files": [
{
"filePath": "",
"fileSize": "",
"iconName": ""
},
...
]
}
</code></pre><p><code>Examples</code><pre><code class="language-json"lang="json">HTTP GET http://192.168.1.99:8080/files?path=/Records
{ "files": [
{
"filePath": "/Records/2019-03-10: 12:00:00.lua",
"fileSize": "12kb",
"iconName": "script"
},
...
]
}
</code></pre><h3 id="newDir">Create a new directory</h3><pre><code>GET /file/newFolder?path=/Test
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th>Specification<tbody><tr><td>path<td>New Directory path to create.</table></figure><p><code>Return</code><p>Successful:<pre><code class="language-json"lang="json">{
"status": "success"
}
</code></pre><p>Failed:<pre><code class="language-json"lang="json">{
"status": "fail",
"info": ""
}
Examples
HTTP GET http://192.168.1.99:8080/file/newFolder?path=/Test
{
"status": "success"
}
</code></pre><h3 id="newFile">Create a new file</h3><pre><code>GET /file/new?path=/newFilePath
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th>Specification<tbody><tr><td>path<td>New file path to make.</table></figure><p><code>Return</code><p>Successful:<pre><code class="language-json"lang="json">{
"status": "success"
}
</code></pre><p>Failed:<pre><code class="language-json"lang="json">{
"status": "fail",
"info": ""
}
</code></pre><p>Examples:<pre><code class="language-json"lang="json">HTTP GET http://192.168.1.99:8080/file/new?path=/newFilePath
{
"status": "fail",
"info": "Invalid file path"
}
</code></pre><h3 id="delFile">Delete a file</h3><pre><code>GET /file/delete?path=/filePathToDelete
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th>Specification<tbody><tr><td>path<td>File path to delete.</table></figure><p><code>Return</code><p>Successful:<pre><code class="language-json"lang="json">{
"status": "success"
}
</code></pre><p>Failed:<pre><code class="language-json"lang="json">{
"status": "fail",
"info": ""
}
</code></pre><p>Examples:<pre><code class="language-json"lang="json">HTTP GET http://192.168.1.99:8080/file/delete?path=/filePathToDelete
{
"status": "fail",
"info": "Invalid file path"
}
</code></pre><h3 id="rename">Rename a file or directory</h3><pre><code>GET /file/rename?path=/oldFilePath&newPath=newFilePath
</code></pre><p><code>Parameters</code><figure><table><thead><tr><th>Parameter<th>Specification<tbody><tr><td>path<td>Old path.<tr><td>newPath<td>New path.</table></figure><p><code>Return</code><p>Successful:<pre><code class="language-json"lang="json">{
"status": "success"
}
</code></pre><p>Failed:<pre><code class="language-json"lang="json">{
"status": "fail",
"info": ""
}
</code></pre><p>Examples:<pre><code class="language-json"lang="json">HTTP GET http://192.168.1.99:8080/file/rename?path=/oldFilePath&newPath=newFilePath
{
"status": "fail",
"info": "Invalid file path"
}
</code></pre><h2 id="constants">Constants</h2><p><a name="types-of-physical-keys"></a><h3 id="physicalKeys">Types of physical keys</h3><figure><table><thead><tr><th>Value<th>Specification<tbody><tr><td>KEY_TYPE.HOME_BUTTON<td>Home Button<tr><td>KEY_TYPE.VOLUME_DOWN_BUTTON<td>Volume – Button<tr><td>KEY_TYPE.VOLUME_UP_BUTTON<td>Volume + Button<tr><td>KEY_TYPE.POWER_BUTTON<td>Power Button</table></figure><p><a name="types-of-dialog-controls"></a><h3 id="dialogControls">Types of dialog controls</h3><figure><table><thead><tr><th>Value<th>Specification<tbody><tr><td>CONTROLLER_TYPE.LABEL<td>Text label<tr><td>CONTROLLER_TYPE.INPUT<td>Input box<tr><td>CONTROLLER_TYPE.PICKER<td>Picker<tr><td>CONTROLLER_TYPE.SWITCH<td>Switch</table></figure><p><a name="types-of-screen-orientations"></a><h3 id="screenOrientation">Types of screen orientations</h3><figure><table><thead><tr><th>Value<th>Specification<tbody><tr><td>ORIENTATION_TYPE.UNKNOWN<td>Unknown orientation. Practical value is 0.<tr><td>ORIENTATION_TYPE.PORTRAIT<td>Portrait screen. Home button is at the bottom. Practical value is 1.<tr><td>ORIENTATION_TYPE.PORTRAIT_UPSIDE_DOWN<td>Upside-down portrait screen. Home button on the top. Practical value is 2.<tr><td>ORIENTATION_TYPE.LANDSCAPE_LEFT<td>Landscape left screen. Home Key is in the left. Practical value is 3.<tr><td>ORIENTATION_TYPE.LANDSCAPE_RIGHT<td>Landscape right screen. Home key is in the right. Practical value is 4.</table></figure><script src="script/prism.js"></script>