Document
1. General
2. Usage
3. Script
AutoTouch is used to record and play back your operations in your mobile device.More often it's used to run the lua script written beforehand to implement more powerful features.You may use it to play games automatically to gain more score and coins, even use it to simulate human operations to test your program with nobody.You have to jailbreak the device before installing AutoTouch.Jailbreak is easy and you can search from the internet.
Now AutoTouch have had the ability to record and play back most of the actions such as touches, home button click, volume button click, ringer switch, lock button click at home screen and any other apps with accurate and smooth experience.It also provides the functions for screenshot,screenshot for region,get color of specified point, find point fit specified color and many others.With these you can already control your device freely and skillfully.
- Make sure you've added the BigBoss source to the Cydia;
- Search and install "AutoTouch" from Cydia;
- It will install the dependent app "Activator" automatically, which is used for control management. Do not remove "Activator" or it will remove "AutoTouch" together.
- At any view you want to record start, hold on the volume down button(or other action you've set to control it with Activator) until there pops up the control panel which contains a record button and a script list;
- Click on the "Record" button, it will start recording immediately with a shot vibrating;
- Then do your touch or other operations;
- When you want to finish recording, hold on the volume down button(or other action said before) until there pops up an alert noticing it's stopped;
- Then you can call out the control panel again by holding on the volume down button to play the script recorded just now, or go ahead to the app to manage it.It uses the create time as the script's filename at default, you can rename it to a more human friendly one.
- At the view where the script will play start, hold on the volume down button(or other action said before) to call out the control panel;
- Click on the script that you want to play;
- Generally(unless you've set it to play directly in the playing settings of AutoTouch app) there will pop up a view asking for the settings of repeat times, interval(seconds) and speed.If you set the time to 0, it will loop infinitely;
- After that, you click on the "Play Now" button, it will start playing immediately with a shot vibrating, and stop with an alert(can be turn off in the settings) when the playing is finished, or you can hold on the volume down button(or other action said before) to interrupt the playing;
- If you click on the "Play Later" button, it will enter the "Ready to Play" mode in which you can repeatedly start or interrupt playing by clicking(not holding, can't be changed in Activator) on the volume down button without any interruptive popup asking.Hold on the volume down button(or other action said before) again, it will quit the "Ready to Play" mode;
- You can set the playing settings for the scripts in the "Playing Settings" view in AutoTouch app, with witch you can make it play directly with the default settings.
- Click the "Action" button at middle of the toolbar, then choose "New File";
- Write in the edit view to make your script;
- Then click the "Save" button to save it.
- It provides two buttons on the accessory of keyboard in the script edit view, one is "Extensions" for inserting the extension functions easily, another is "Statements" for inserting common statements of Lua language easily;
- Click on the "Extensions" button, it presents a functions choosing list, click on the function there, it will insert the function to the editing script;
- In the functions choosing list, you will see some "HELPER" buttons beside the functions, click on them, it will present the help views, which provides there helpers: coordinates choosing, colors choosing, app identifier choosing, key button choosing.Eh, you've known it? They are easy to understand when you trying them, but one thing I should explain a little more: when opening the coordinates choosing or colors choosing views, it will ask you to open a image from the album, then zoom in the image until the pixels are clear, click on the pixels will get the coordinates or colors of them, the choosing pixels will change to red color to as marked. Now, I think everything is clear;
- Click on the "Statements" button, it presents a statemens choosing list, just choose what you need there.
- Click on the script in AutoTouch, select the "Encrypt" option;
- Input the password, if you don't want a password just leave it blank.
- Confirm to encrypt it, then it will generate a file with the same name but .lua.e suffix.
- You can play the encrypted scripts just as playing .lua scripts, if it ask for password just input it.
- You can turn on the Web Server at the settings view, visit the prompt url in the browsers at desktop, then edit the scripts there;
- Also you can turn on the WebDAV Server at the settings view, connect the server with the WebDAV client at desktop, then edit scripts the scripts there,about WebDAV;
- Click on the "License" in the "Settings" view to open the license infomation view;
- It will validate you license when open the license infomation view;
- If you are not validated, you will find the "Pay with Paypal" button, just click on it;
- Then you will switch to the Safari browser window, finish the payment on Paypal official payment site, it is safe;
- When payment is finished, switch to the "Settings" view of AutoTouch, click on the "License", it will validate the license if you have connection to the internet;
- When the license is validated, you will have all the features of the app.
- You can download any script from the store directly;
- Some of the scripts may be encrypted, some may need password to decrypt to run, if need password, you should connect with the author to buy the password;
- Downloaded scripts are in the script list, use them as others.
- You can release your scripts in the store to share or sell to others;
- If you just want to share the scripts, you may upload the .lua files directly, if you don't want others know how you implement it, just encrypt them;
- If you want to sell your scripts, you should encrypt them and make sure you've set the passwords so that when someone need them could buy from you.
You can learn lua from Lua Official Reference Manual to know how to use it.
The extended functions are provided by AutoTouch to give some powerful features on mobile device, with which you can simulate touch operations,find color or image from the screen, etc.
touch on the point(x, y) and set the event id.
- Params
- id: the id you speficified for this event.
- x: the x-coordinate you want to touch down at.
- y: the y-coordinate you want to touch down at.
- Return
- Examples
touchDown(0, 100, 200); -- touch down at point(100, 200).
touch move to the point(x, y).
- Params
- id: the id your touch continues from.
- x: the x-coordinate you want to touch move to.
- y: the y-coordinate you want to touch move to.
- Return
- Examples
touchDown(0, 100, 200); -- touch down at point(100, 200).
touchMove(0, 200, 200); -- touch move to point(200, 200).
touch up from the point(x, y).
- Params
- id: the id your touch continues from.
- x: the x-coordinate you want to touch up from.
- y: the y-coordinate you want to touch up from.
- Return
- Examples
touchDown(0, 100, 200); -- touch down at point(100, 200).
touchMove(0, 200, 200); -- touch move to point(200, 200).
touchUp(0, 200, 200); -- touch up from point(200, 200).
tap at the point(x, y).
- Params
- x: the x-coordinate you want to tap at.
- y: the y-coordinate you want to tap at.
- Return
- Examples
tap(100, 200); -- tap at point(100, 200).
Simulate a key button down event.
- Params
-
keyType: the keyType you want to simulate, now you can use these key type.
- Return
- Examples
keyDown(KEY_TYPE.HOME_BUTTON);
-- Simulate a home button down event.
-- how to make a key press
function keyPress(keyType)
keyDown(keyType);
usleep(10000);
keyDown(keyUp);
end
keyPress(KEY_TYPE.HOME_BUTTON);
Simulate a key button up event.
- Params
keyType: the keyType you want to simulate, now you can use these key type.
- Return
- Examples
keyUp(KEY_TYPE.HOME_BUTTON);
-- Simulate a home button up event.
Get the RGB color value of the specified point on the screen.
- Params
- x: the x-coordinate in iOS coordinate system of the point you want to get the color.
- y: the y-coordinate in iOS coordinate system of the point you want to get the color.
- Return
- rgb: the rgb value of the color.
- Examples
local rgb = getColor(100, 200);
alert("rgb:" .. rgb);
-- rgb:16777215
Find all the pixels fit the specified color on the current screen, and return the coordinates of them as table.You can use the count parameter to limit the result number of finding, pass in 0 if no limit, and use region to limit the region of finding, pass in nil if no limit.
- Params
- color: the int type rgb value of the color.
- count: how many at most you want to find out, pass in 0 by default, means all the fit ones in the screen should be found.count=1 means only the first fit one should be found, count=2 means the first two should be found. It will be faster if you set this parameter to a small value.
- region: The region you want to find in. This parameter is a table contains 4 elements:left-top x-coordinate, left-top y-coordinate, region width, region height. Use like this {100, 100, 200, 200}. Pass in nil if you don't want any limit. ATTENTION: all the 4 elements are in the iOS coordinate system.
- Return
- locations: a table ccontains the locations of the pixels fit the specified color. Looks like {{x1, y1}, {x2, y2}, ...}.
- Examples
-- example 1:
local result = findColor(0x0000ff, 2, nil);
for i, v in pairs(result) do
log("x:" .. v[1] .. ", y:" .. v[2]);
end
-- example 2:
local result = findColor(0x00ddff, 0, {100, 50, 200, 200});
for i, v in pairs(result) do
log("x:" .. v[1] .. ", y:" .. 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("x:" .. v[1] .. ", y:" .. v[2]);
end
Find all the regions(rectangles) contain the specified colors and fit their relative positions on the screen, return the center coordinates of the regions as table. You can use the count parameter to limit the result number of finding, pass in 0 if no limit, and use region to limit the region of finding, pass in nil if no limit.
There is a powerful help tool in the script edit view, click on the "Extensions" to open the function list, click "HELPER" besides the findColors function, it will ask you to choose and open a screenshot from the album, zoom in the screenshot till the pixels are clear, click on the pixels you want to mark as anchor points, then it will get the colors and their relative positions, it will construct the "colors" parameters while you are marking, it's very intuitionistic.
- Params
- colors: a table contains some colors and their relative positions that can determine a region on the screen, for example {{0x00ddff,0,0}, {0x00eeff,10,10}, {0x0000ff,0,20}}, the little table contains three elements inside that big table means {color, relative_first_element_x, relative_first_element_y}, the relative position of first color always is (0,0), as you look, it is {0x00ddff,0,0}, meanwhile, the relative postion of other colors are the postions relative to the first color, {0x00eeff,10,10} means is is x:10,y:10 relative to the first color.With these colors and the relative positons, we can determine the regions on the screen.
- count: how many at most you want to find out, pass in 0 by default, means all the fit ones in the screen should be found.count=1 means only the first fit one should be found, count=2 means the first two should be found. It will be faster if you set this parameter to a small value.
- region: The region you want to find in, that's different with the region we've mentioned in the colors parameter. This region is a table contains 4 elements:left-top x-coordinate, left-top y-coordinate, region width, region height. Use like this {100, 100, 200, 200}. Pass in nil if you don't want any limit. ATENSION: all the 4 elements are in the iOS coordinate system.
- Return
- locations: a table ccontains the center locations of the regions fit the specified color. Looks like {{x1, y1}, {x2, y2}, ...}.ATTENSION: it returns the center coordinates of the regions found out, not the left-top coordinates.
- Examples
-- example 1:
local result = findColors({{0x00ddff,0,0}, {0x00eeff,10,10}, {0x0000ff,0,20}}, 2, nil);
for i, v in pairs(result) do
log("x:" .. v[1] .. ", y:" .. 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("x:" .. v[1] .. ", y:" .. 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("x:" .. v[1] .. ", y:" .. v[2]);
end
Find the regions similar to the specified image on the screen, return the center coordinates of the regions as table. ATENSION: from AutoTouch v3.1.1 on, the parameter of findImage is not a table as the old versions before anymore, you have to pass in the parameters one by one, event you don't want , you shold pass in the default value, such as 0, nil, etc.
- Params
- imagePath: the path of the small image you want to find out from the screen, such as the spirit image in the game. ATTENSION: the image path is the path that's relative to the root dir path (that is the defalut document directory path of AutoTouch, also is the result of rootDir() function), not the exact whole path, just the same as the file path of screenshot function. For example, a path "images/spirit.png" means "/var/mobile/Library/AutoTouch/Scripts/images/spirit.png" in fact, namely, it is rootDir() joins "images/spirit.png", never pass in a exact whole path, no whole path anymore from AutoTouch v
- count: how many at most you want to find out, pass in 0 by default, means all the fit ones in the screen should be found.count=1 means only the first fit one should be found, count=2 means the first two should be found.It will be faster when you set this parameter to a small value.
- fuzzy: the degree of fuzzy matching when finding, pass in 1 by default, means match exactly, fuzzy=0.5 means match 50%.
- ignoreColors: a table contains the colors will be ignored when finding, pass in nil by default, means no ignore colors.
- region: The region you want to find in. This parameter is table contains 4 elements:left-top x-coordinate, left-top y-coordinate, region width, region height. Use like this {100, 100, 200, 200}. Pass in nil if you don't want any limit. ATENSION: all the 4 elements are in the iOS coordinate system.
- Return
- locations: a table contains the center coordinates of the regions fit the specified image. Looks like {{x1, y1}, {x2, y2}, ...}. ATTENSION: it returns the center coordinates of the regions found out, not the left-top coordinates.
- Examples
-- example 1:
local result = findImage("images/spirit.png", 5, 1, nil, nil);
for i, v in pairs(result) do
log("x:" .. v[1] .. ", y:" .. v[2]);
end
-- example 2:
local result = findImage("images/spirit.png", 0, 0.6, nil, nil};
for i, v in pairs(result) do
log("x:" .. v[1] .. ", y:" .. v[2]);
end
-- example 3:
local result = findImage("images/spirit.png", 0, {0xffffff, 0x2b2b2b}, nil};
for i, v in pairs(result) do
log("x:" .. v[1] .. ", y:" .. v[2]);
end
-- example 4:
local region = {100, 50, 200, 200};
local ignoreColors = {0xffffff, 0x2b2b2b};
local result = findImage("images/spirit.png", 1, 0.9, ignoreColors, region};
for i, v in pairs(result) do
log("x:" .. v[1] .. ", y:" .. v[2]);
end
As it looks like, this function finds out the pixels (totally same as findColor does we've talked about before), and tap them a time one by one with 0.016 second interval. It's parameters are totally the same as findColor function, and it doesn't return anything.
- Params
- totoally same as the params of findColor
- Return
- Examples
-- example 1:
findColorTap(0x0000ff, 2, nil); -- find out the first two pixels which's colors are 0x0000ff, then tap them a time one by one.
-- example 2:
local region = {100, 50, 200, 200};
findColorTap(0x0000ff, 0, region); -- find out all the pixels fit color 0x0000ff, then tap them a time one by one.
As it looks like, this function finds out the regions (totally same as findColors does we've talked about before), and tap them a time one by one with 0.016 second interval. It's parameters are totally the same as findColor function, and it doesn't return anything.
- Params
- totoally same as the params of findColors
- Return
- Examples
findColors({{0x00ddff,0,0}, {0x00eeff,10,10}, {0x0000ff,0,20}}, 2, nil); -- find out the first two regions fit the specified colors and their relative positions, then tap them a time one by one.
local region = {100, 50, 200, 200};
findColors({{0x00ddff,0,0}, {0x00eeff,10,10}, {0x0000ff,0,20}}, 2, region); -- find out all the regions, then tap them a time one by one.
As it looks like, this function finds out the regions (totally same as findColor does we've talked about before), and tap them a time one by one with 0.016 second interval. It's parameters are totally the same as findColor function, and it doesn't return anything.
- Params
- totoally same as the params of findColor
- Return
- Examples
local region = {100, 50, 200, 200};
local ignoreColors = {0xffffff, 0x2b2b2b};
findImageTap("images/spirit.png", 1, 0.9, ignoreColors, region};
Take a screenshot of the whole screen or just a region and save it to the specified file path.
- Params
- filePath: The path that you want the screenshot be saved. ATTENSION: the file path is the path that's relative to the root dir path (that is the defalut document directory path of AutoTouch, also is the result of rootDir() function), not the exact whole path, just the same as the image path of findImage function. For example, a path "images/spirit.png" means "/var/mobile/Library/AutoTouch/Scripts/images/spirit.png" in fact, namely, it is rootDir() joins "images/spirit.png", never pass in a exact whole path, no whole path anymore from AutoTouch v
- region: The region you want to take a screenshot.This parameter is table type and contains 4 elements:left-top x-coordinate, left-top y-coordinate, region width, region height.Use like this region={100, 100, 200, 200}, do not use like region={x=100, y=100, width=200, height=200}.Pass in this parameter only when you want to take the screenshot of a region. And all the 4 elements are in the iOS coordinate system.
- Return
- Examples
screenshot ("images/screenshot1.png", nil);
-- Take a screenshot and save it to the specified path.
screenshot ("images/screenshot1.png", {100, 100, 200, 200});
-- Take a screenshot of region(100, 100, 200, 200) and save it to the specified path.
Run the app by its identifier.
- Params
- appIdentifier: the identifier of the app you want to run, such as "com.apple.mobilesafari".
- Return
- Examples
appRun("com.apple.mobilesafari");
-- run safari
Kill the app by its identifier.
- Params
- appIdentifier: the identifier of the app you want to kill, such as "com.apple.mobilesafari".
- Return
- Examples
appKill("com.apple.mobilesafari");
-- kill running safari
get the state of the specified app with its identifier.
- Params
- appIdentifier: the identifier of the app, such as "com.apple.mobilesafari".
- Return
- state: string type state, they are: "NOT RUNNING", "ACTIVATED", "DEACTIVATED".
- Examples
b = appState("com.apple.mobilesafari");
-- get the state of Safari.
Check if the app is active and at front most with its identifier.
- Params
- appIdentifier: the identifier of the app you want to check, such as "com.apple.mobilesafari".
- Return
- ifAppIsActive: bool type result.
- Examples
b = appIsActive("com.apple.mobilesafari");
-- check if the app is active
Get the root path of the dir you place the scripts in.
- Params
- Return
- The path string of the root dir.
- Examples
local dirPath = rootDir();
-- dirPath = "/var/mobile/Library/AutoTouch/Scripts/"
Sleep the process for microseconds.
- Params
- microseconds: the time you want to sleep for.
- Return
- Examples
usleep(1000000);
-- Sleep one second
Take log of the string type log content.See log in the log view
- Params
- logContent: the content you want to log.
- Return
- Examples
log("play here...");
Open an alert view to show the message.
- Params
- message: the message you want to show with alert view.
- Return
- Examples
alert("Hello world!");
Take a vibration.
vibrate();
-- Take a vibration for a time.
Play the specified audio file, times means how may time you want to play, default is 0, means infinitely.
- Params
- audioFile: the audio file path.
- times: how many times to play, default is 0, means infinitely.
- Return
- Examples
playAudio("/var/audio.mp3", 0); -- play infinitely.
Pause the playing started before.
pauseAudio();
Resume the paused playing before.
resumeAudio();
Stop the playing started before.
stopAudio();
Get the resolution of your device screen.
- Params
- Return
- width: The width resolution of your device.
- height: The height resolution of your device.
- Examples
local w, h = getScreenResolution();
-- width is 1136, height is 640 for iPhone 5
Get the size of your device screen in iOS coordinate system.
- Params
- Return
- width: The width of your device screen.
- height: The height of your device screen.
- Examples
local width, height = getScreenSize();
-- width is 320, height is 568 for iPhone 5
Get the retina scale of the screen.
- Params
- Return
- scale: The retina scale of the screen.
- Examples
local scale = getScreenScale();
-- 2.0 for iPhone 5, 3.0 for iPhone 6 Plus.
Get the bit depth of the screen.
- Params
- Return
- bitDepth: The retina bit depth of the screen.
- Examples
local bitDepth = getScreenBitDepth();
Retrieve the Serial Number of the device.
- Params
- Return
- Serial Number: string type result.
- Examples
b = getSN();
-- b: C15NFK32TWD2
Retrieve the current version of AutoTouch.
- Params
- Return
- AutoTouch version: string type result.
- Examples
b = getVersion();
-- b: 3.0.1
Convert an int type of color value to r, g, b type.
- Params
- intColor: the int type of color value.
- Return
- r: red value of the color.
- g: green value of the color.
- b: blue value of the color.
- Examples
local r, g, b = intToRgb(0x2b2b2b);
Convert rgb type of color value to integer type.
- Params
- r: the red value of the color.
- g: the green value of the color.
- b: the blue value of the color.
- Return
- intColor: int type of the color value.
- Examples
local intColor = rgbToInt(200, 255, 100);
Copy specified text to the clipboard, which can be used later.
- Params
- text: the text to be copied.
- Return
- Examples
copyText("This is a copied text!");
Get the text on the clipboard.
- Params
- Return
- text: string type of text on the clipboard.
- Examples
local text = clipText();
Input the specified text to the focused text field.
- Params
- text: the text will be inputted.
- Return
- Examples
inputText("Let's input some text automatically without tapping the keyboard!");
inputText("\b\b\b"); -- delete backward for 3 characters
Fake geographic position for the specified apps, it remains in effect until you call clearFakeLocation, or clear the faking in the settings view.
- Params
- appIdentifier: the identifier of the app you want to fake, such as "com.apple.Maps".
- latitude: the double type latitude value.
- longitude: the double type longitude value.
- Return
- Examples
fakeLocation("com.apple.Maps", 36, 50); -- fake location for Apple Map.
Clear the location faking for one specified app.
- Params
- appIdentifier: the identifier of the app you want to fake, such as "com.apple.Maps".
- Return
- Examples
clearFakeLocation("com.apple.Maps"); -- clear the location faking for Apple Map.
Show a dialog accepts user input.
- Params
- controls: see the example.Now CONTROLLER_TYPE.LABEL, CONTROLLER_TYPE.INPUT, CONTROLLER_TYPE.PICKER, CONTROLLER_TYPE.SWITCH are supported.
- enableRemember: if enable the switch for users to set remembering the input, if remembered, will use the saved values directly, without showing the dialog again. You can clear the remembered values at the accessory button actions at the script list view.
- Return
- Examples
local label = {type=CONTROLLER_TYPE.LABEL, text="Would you mind to provide some personal informations?"}
local nameInput = {type=CONTROLLER_TYPE.INPUT, title="Name:", key="Name", value="Kevin"}
local positionPicker = {type=CONTROLLER_TYPE.PICKER, title="Position:", key="Position", value="CEO", options={"CEO", "CTO", "CFO", "CXO"}}
local developerSwitch = {type=CONTROLLER_TYPE.SWITCH, title="A Developer:", key="ADeveloper", value=1}
local controls = {label, nameInput, positionPicker, developerSwitch}
local enableRemember = true;
dialog(controls, enableRemember);
alert(string.format("name:%s, birthday:%s, gender:%d", nameInput.value, positionPicker.value, developerSwitch.value))
Get the screen orientation.
local o = getOrientation();
- KEY_TYPE.HOME_BUTTON
- KEY_TYPE.VOLUME_DOWN_BUTTON
- KEY_TYPE.VOLUME_UP_BUTTON
- KEY_TYPE.POWER_BUTTON
- CONTROLLER_TYPE.LABEL
- CONTROLLER_TYPE.INPUT
- CONTROLLER_TYPE.PICKER
- CONTROLLER_TYPE.SWITCH
- ORIENTATION_TYPE.UNKNOWN
- ORIENTATION_TYPE.PORTRAIT PORTRAIT = 1, -- Device oriented vertically, home button on the bottom
- ORIENTATION_TYPE.PORTRAIT_UPSIDE_DOWN PORTRAIT_UPSIDE_DOWN = 2, -- Device oriented vertically, home button on the top
- ORIENTATION_TYPE.LANDSCAPE_LEFT LANDSCAPE_LEFT = 3, -- Device oriented horizontally, home button on the right
- ORIENTATION_TYPE.LANDSCAPE_RIGHT LANDSCAPE_RIGHT = 4 -- Device oriented horizontally, home button on the left