AutoTouch Document

Fit for v4.3.8 and above

AutoTouch DocumentUsageHow to install?How to use Activator?How to record?How to play script?How to set play settings for script?How to take screenshot?How to write a script?How to use the "Function Helper" while script coding?How to write and manage scripts on the computer?How to use Package to orgainize the script project?How to encrypt the scripts?How to sell your script in Script Store?How to download and buy scripts from Script Store?How to buy AutoTouch license?ScriptBasisDevelop ToolCoordinate, Size and Orientation SystemExtension FunctionstouchDown(id, x, y)touchMove(id, x, y)touchUp(id, x, y)keyDown(keyType)keyUp(keyType)getColor(x, y)getColors(locations)findColor(color, count, region)findColors(colors, count, region)findImage(imagePath, count, fuzzy, ignoreColors, region)screenshot(filePath, region)appRun(appIdentifier)appKill(appIdentifier)appState(appIdentifier)rootDir()usleep(microseconds)log(content)alert(message)toast(message, delay)vibrate()playAudio(audioFile, times)stopAudio()getOrientation()getScreenResolution()getSN()getVersion()intToRgb(intColor)rgbToInt(r, g, b)copyText(text)clipText()inputText(text)dialog(controls, enableRemember)clearDialogValues(script)Some ConstantsTypes of physical keysTypes of dialog controlsTypes of screen orientations

Usage

How to install?

How to use Activator?

How to record?

How to play script?

How to set play settings for script?

How to take screenshot?

How to write a script?

How to use the "Function Helper" while script coding?

How to write and manage scripts on the computer?

How to use Package to orgainize the script project?

How to encrypt the scripts?

How to sell your script in Script Store?

How to download and buy scripts from Script Store?

How to buy AutoTouch license?

Script

Basis

You can learn how to use Lua language from here:《Lua Official Reference Manual

Develop Tool

LuaStudio is aprofessional development environment for debugging Lua script in your applications. It's familiar and fast and you'll wonder how you ever worked without it.

Coordinate, Size and Orientation System

AutoTouch uses pixel based Native Resolution as the coordinate and size system. Resolutions of different iOS devices are here, for example, screen size of iPhone X is 1125 x 2436.

Origin point (0, 0) is alwasy at left-top of the Application Interface, regardless of the device orientation. Consider only the App interface while using these functions: touchDown,touchMove,touchUp,getColors,findColors,findImage.

For example

Extension Functions

Extension functions are used to extend Lua language. Thus, the device can simulate some human abilities of operating the mobile phone. Moreover, extension functions also support functions including: screenshot, color searching, color matching, and picture matching.

touchDown(id, x, y)

Parameters

ParameterTypeSpecification
idIntegerFinger ID. is used to mark a finger in single-touch or multi-touch.
xFloatx-coordinate on the screen
yFloaty-coordinate on the screen

Return None

Examples

touchMove(id, x, y)

Parameters

ParameterTypeSpecification
idIntegerFinger ID. is used to mark a finger in single-touch or multi-touch.
xFloatx-coordinate on the screen
yFloaty-coordinate on the screen

Return None

Examples

touchUp(id, x, y)

Parameters

ParameterTypeSpecification
idIntegerFinger ID. is used to mark a finger in single-touch or multi-touch.
xFloatx-coordinate on the screen
yFloaty-coordinate on the screen

Return None

Examples

keyDown(keyType)

Parameters

ParameterTypeSpecification
keyTypeIntegerPhysical key identification. Now you can use these physical keys.

Return None

Examples

keyUp(keyType)

Parameters

ParameterTypeSpecification
keyTypeIntegerPhysical key identification. Now you can use these physical keys.

Return None

Examples

getColor(x, y)

Parameters

ParameterTypeSpecification
xFloatx-coordinate on the screen
yFloaty-coordinate on the screen

Return

ReturnTypeSpecification
colorIntegerInteger color value of the pixel point

Examples

getColors(locations)

Parameters

ParameterTypeSpecification
locationstableA grouo of coordinates, just as {{x1,y1},{x2,y2},{x3,y4}}

Return

ReturnTypeSpecification
colorstableColors gotten with corresponding order.

Examples

findColor(color, count, region)

Parameters

ParameterTypeSpecification
colorIntegerMatched color value.
countIntegerThe number refers to how many matched pixel points is found at most. 0 is default setting, which shows all matching points are found. 1 refers to only the first matching pixel point is found. 2 refers to only the first two pixel points are found. The less the number is, the faster the speed is.
regiontableYou 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.

Return values

Return valueTypeSpecification
locationstableCoordinates of matched pixel points. For example: {{x1, y1}, {x2, y2}, ...}

Example

Internal Implementation

findColors(colors, count, region)

IMG_0361.PNG-101.9kB

Parameters

ParameterTypeSpecification
colorstableInclude some color and their corresponding location, such as:{{0x00ddff,0,0}, {0x00eeff,10,10}, {0x0000ff,0,20}}. The small table in the big table includes 3 values: the first is the color value. The second and the third are the corresponding locations of the colors to the first color. The corresponding location of the first color’s table is always (0,0). {0x00ddff,0,0} is an example. The location values of the successive colors are their locations corresponding to the first color. The matched rectangular area can be found on the screen upon these colors and corresponding location relation.
countIntegerThe number refers to how many matched pixel points is found at most. 0 is default setting, which shows all matching points are found. 1 refers to only the first matching pixel point is found. 2 refers to only the first two pixel points are found. The less the number is, the faster the speed is.
regiontableYou 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.

Return values

Return valueTypeSpecification
locationstableThe coordinate of the first color matched in the found rectangular area, including {{x1, y1}, {x2, y2}, ...}

Examples

findImage(imagePath, count, fuzzy, ignoreColors, region)

Parameters

ParameterTypeSpecification
imagePathStringThe path of picture to be searched. From AutoTouch v3.1.1, you need not input complete path here, but 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.
countIntegerThe number refers to how many matched pixel points is found at most. 0 is default setting, which shows all matching points are found. 1 refers to only the first matching pixel point is found. 2 refers to only the first two pixel points are found. The less the number is, the faster the speed is.
fuzzyfloatThe floating degree of the search. 1 is default setting and refers to complete matching. 0.5 refers to 50%v of matching.
ignoreColorstableThe color value to be ignored in the search is provided by array, such as {0xffffff, 0x2b2b2b}. You can input nil if one.
regiontableYou 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.

Return values

Return valueTypeSpecification
locationstableThe array at the coordinate on the top left corner of the matched area: {{x1, y1}, {x2, y2}, ...}

Examples

screenshot(filePath, region)

Parameters

ParameterTypeSpecification
filePathstringThe 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.
regiontableYou make a screenshot of 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.

Return values None

Examples

appRun(appIdentifier)

Parameters

ParameterTypeSpecification
appIdentifierstringApplication identifier, including "com.apple.mobilesafari".

Return values None

Example

appKill(appIdentifier)

Parameters

ParameterTypeSpecification
appIdentifierstringApplication identifier, including "com.apple.mobilesafari".

Return values None

Example

appState(appIdentifier)

Parameters

ParameterTypeSpecification
appIdentifierstringApplication identifier, including "com.apple.mobilesafari".

Return values

Return valueTypeSpecification
statestringState of Character string type: "NOT RUNNING", "ACTIVATED", "DEACTIVATED"。

Example

rootDir()

Parameters None

Return values

Return valueTypeSpecification
dirstringDefault directory address of the saved script.

Examples

usleep(microseconds)

Sleep several microseconds (1/1000000)

Parameters

ParameterTypeSpecification
microsecondsIntegerThe number of paused microseconds.

Return values None

Examples

log(content)

Record log, can be seen in the log interface.

Parameters

ParameterTypeSpecification
contentstringThe log content to be recorded.

Return values None

Examples

alert(message)

Pop up the dialog box to show specified content.

Parameters

ParameterTypeSpecification
messagestringContent to be showed.

Return values None

Examples

toast(message, delay)

Show messages with Toast style and delay for some seconds.

Parameters

ParameterTypeSpecification
messagestringContent to be showed.
delayintegerHow long time to keep showing, default is 2 seconds.

Return values None

Examples

vibrate()

Vibrate once.。

Parameters None

Return values None

Examples

playAudio(audioFile, times)

Play audio document at specified location.

Parameters

ParameterTypeSpecification
audioFilestringAbsolute path of audio document.
timesintegerNumber of repeated plays. 0 represents infinite repeat.

Return values None

Examples

stopAudio()

Stop playing audio.

Parameters None

Return values None

Examples

getOrientation()

Get orientation of the screen. Return the integer value. Please refer to the “Orientation Type of Screen” for specific correspondence relation.

Parameters None

Return values

Return valueTypeSpecification
orientationIntegerScreen orientation may be these values

示例

getScreenResolution()

Get screen resolution bese on pixels.

Parameters None

Return values

Return valueTypeSpecification
widthIntegerWidth of screen resolution.
heightIntegerHeight of screen resolution.

Examples

getSN()

 Get Serial Number of the device.

Parameters None

Return values

Return valueTypeSpecification
SNstringSerial Number of the device.

Examples

getVersion()

Get version of AutoTouch.

Parameters None

Return values

Return valueTypeSpecification
versionstringVersion of AutoTouch.

Examples

intToRgb(intColor)

Transit integer color to independent values of R,G,B.

Parameters

ParameterTypeSpecification
intColorIntegerInteger color value

Return values

Return valueTypeSpecification
RIntegerRed color value.
GIntegerGreen color value.
BIntegerBlue color value.

Examples

rgbToInt(r, g, b)

Transit values of R,G,B to integer color value.

Parameters

ParameterTypeSpecification
RIntegerRed color value.
GIntegerGreen color value.
BIntegerBlue color value.

Return values

Return valueTypeSpecification
intColorIntegerInteger color value

Examples

copyText(text)

Copy specified text to clipboard.

Parameters

ParameterTypeSpecification
textstringText to be copied.

Return values None

Examples

clipText()

Get the text in the clipboard.

Parameters None

Return values

Return valueTypeSpecification
textstringText copied in the clipboard.

Examples

inputText(text)

Input text to the input box selected now. You can delete a character backspace by inputText("\b").

Parameters

ParameterTypeSpecification
textstringText to be input.

Return values None

Examples

dialog(controls, enableRemember)

Pop up self-defined dialog box to accept the user input. Please refer to the example for specific usage.

Parameters

ParameterTypeSpecification
controlstableArray of self-defined controls. You can now use these dialog box controls
enableRememberbooleanWhether to use the "remember user's input" function.

Return values None

Examples

3.png-115.9kB

clearDialogValues(script)

Clear the remembered values of the dialog created by the function dialog.

Parameters

ParameterTypeSpecification
scriptstringscript path. eg. there is a dialog.lua script in the scripts list, use it like this: clearDialogValues("dialog.lua");

Return values None

Examples

Some Constants

Types of physical keys

ValueSpecification
KEY_TYPE.HOME_BUTTONHome Button
KEY_TYPE.VOLUME_DOWN_BUTTONVolume – Button
KEY_TYPE.VOLUME_UP_BUTTONVolume + Button
KEY_TYPE.POWER_BUTTONPower Button

Types of dialog controls

ValueSpecification
CONTROLLER_TYPE.LABELText label
CONTROLLER_TYPE.INPUTInput box
CONTROLLER_TYPE.PICKERPicker
CONTROLLER_TYPE.SWITCHSwitch

Types of screen orientations

ValueSpecification
ORIENTATION_TYPE.UNKNOWNUnknown orientation. Practical value is 0.
ORIENTATION_TYPE.PORTRAITPortrait screen. Home button is at the bottom. Practical value is 1.
ORIENTATION_TYPE.PORTRAIT_UPSIDE_DOWNUpside-down portrait screen. Home button on the top. Practical value is 2.
ORIENTATION_TYPE.LANDSCAPE_LEFTLandscape left screen. Home Key is in the left. Practical value is 3.
ORIENTATION_TYPE.LANDSCAPE_RIGHTLandscape right screen. Home key is in the right. Practical value is 4.