Document

1. General
2. Usage
3. Script

1. General

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.


2. Usage

2.1. How to install?

  1. Make sure you've added the BigBoss source to the Cydia;
  2. Search and install "AutoTouch" from Cydia;
  3. It will install the dependent app "Activator" automatically, which is used for control management. Do not remove "Activator" or it will remove "AutoTouch" together.

2.2. How to record your operations?

  1. 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;
  2. Click on the "Record" button, it will start recording immediately with a shot vibrating;
  3. Then do your touch or other operations;
  4. 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;
  5. 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.

2.3. How to play the scripts?

  1. 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;
  2. Click on the script that you want to play;
  3. 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;
  4. 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;
  5. 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;
  6. 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.

2.4. How to write a script?

  1. Click the "Action" button at middle of the toolbar, then choose "New File";
  2. Write in the edit view to make your script;
  3. Then click the "Save" button to save it.

2.5. How to insert functions with the helpers when editing scripts?

  1. 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;
  2. 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;
  3. 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;
  4. Click on the "Statements" button, it presents a statemens choosing list, just choose what you need there.

2.6. How to encrypt a script?

  1. Click on the script in AutoTouch, select the "Encrypt" option;
  2. Input the password, if you don't want a password just leave it blank.
  3. Confirm to encrypt it, then it will generate a file with the same name but .lua.e suffix.
  4. You can play the encrypted scripts just as playing .lua scripts, if it ask for password just input it.

2.7. How to manage the scripts from computer?

  1. 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;
  2. 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;

2.8. How to buy a license?

  1. Click on the "License" in the "Settings" view to open the license infomation view;
  2. It will validate you license when open the license infomation view;
  3. If you are not validated, you will find the "Pay with Paypal" button, just click on it;
  4. Then you will switch to the Safari browser window, finish the payment on Paypal official payment site, it is safe;
  5. 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;
  6. When the license is validated, you will have all the features of the app.

2.9. How to download and buy script from the store?

  1. You can download any script from the store directly;
  2. 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;
  3. Downloaded scripts are in the script list, use them as others.

2.10. How to release your script in the store?

  1. You can release your scripts in the store to share or sell to others;
  2. 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;
  3. 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.

3. Script

3.1. Basic

You can learn lua from Lua Official Reference Manual to know how to use it.


3.2. Extended functions

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.


touchDown(id, x, y)

touch on the point(x, y) and set the event id.

touchDown(0, 100, 200); -- touch down at point(100, 200).

touchMove(id, x, y)

touch move to the point(x, y).

touchDown(0, 100, 200); -- touch down at point(100, 200).
touchMove(0, 200, 200); -- touch move to point(200, 200).

touchUp(id, x, y)

touch up from the point(x, y).

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(x, y)

tap at the point(x, y).

tap(100, 200); -- tap at point(100, 200).

keyDown(keyType)

Simulate a key button down event.

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);

keyUp(keyType)

Simulate a key button up event.

keyUp(KEY_TYPE.HOME_BUTTON);
-- Simulate a home button up event.

getColor(x, y)

Get the RGB color value of the specified point on the screen.

local rgb = getColor(100, 200);
alert("rgb:" .. rgb);
-- rgb:16777215

findColor(color, count, region)

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.

-- 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

findColors(colors, count, region)

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.

-- 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

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

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.

-- 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

findColorTap(color, count, region)

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.

-- 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.

findColorsTap(colors, count, region)

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.

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.

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

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.

local region = {100, 50, 200, 200};
local ignoreColors = {0xffffff, 0x2b2b2b};
findImageTap("images/spirit.png", 1, 0.9, ignoreColors, region};

screenshot(filePath, {x, y, width, height})

Take a screenshot of the whole screen or just a region and save it to the specified file path.

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.

appRun(appIdentifier)

Run the app by its identifier.

appRun("com.apple.mobilesafari");
-- run safari

appKill(appIdentifier)

Kill the app by its identifier.

appKill("com.apple.mobilesafari");
-- kill running safari
      

appState(appIdentifier)

get the state of the specified app with its identifier.

b = appState("com.apple.mobilesafari");
-- get the state of Safari.
      

appIsActive(appIdentifier)

Check if the app is active and at front most with its identifier.

b = appIsActive("com.apple.mobilesafari");
-- check if the app is active
      

rootDir()

Get the root path of the dir you place the scripts in.

local dirPath = rootDir();
-- dirPath = "/var/mobile/Library/AutoTouch/Scripts/"

usleep(microseconds)

Sleep the process for microseconds.

usleep(1000000);
-- Sleep one second

log(logContent)

Take log of the string type log content.See log in the log view

log("play here...");

alert(message)

Open an alert view to show the message.

alert("Hello world!");

vibrate()

Take a vibration.

vibrate();
-- Take a vibration for a time.

playAudio(audioFile, times)

Play the specified audio file, times means how may time you want to play, default is 0, means infinitely.

playAudio("/var/audio.mp3", 0); -- play infinitely.

pauseAudio()

Pause the playing started before.

pauseAudio();

resumeAudio()

Resume the paused playing before.

resumeAudio();

stopAudio()

Stop the playing started before.

stopAudio();

getScreenResolution()

Get the resolution of your device screen.

local w, h = getScreenResolution();
-- width is 1136, height is 640 for iPhone 5

getScreenSize()

Get the size of your device screen in iOS coordinate system.

local width, height = getScreenSize();
-- width is 320, height is 568 for iPhone 5

getScreenScale()

Get the retina scale of the screen.

local scale = getScreenScale();
-- 2.0 for iPhone 5, 3.0 for iPhone 6 Plus.

getScreenBitDepth()

Get the bit depth of the screen.

local bitDepth = getScreenBitDepth();

getSN()

Retrieve the Serial Number of the device.

b = getSN();
          -- b: C15NFK32TWD2
      

getVersion()

Retrieve the current version of AutoTouch.

b = getVersion();
          -- b: 3.0.1
      

intToRgb(intColor)

Convert an int type of color value to r, g, b type.

local r, g, b = intToRgb(0x2b2b2b);

rgbToInt(r, g, b)

Convert rgb type of color value to integer type.

local intColor = rgbToInt(200, 255, 100);

copyText(text)

Copy specified text to the clipboard, which can be used later.

copyText("This is a copied text!");

clipText()

Get the text on the clipboard.

local text = clipText();

inputText(text)

Input the specified text to the focused text field.

inputText("Let's input some text automatically without tapping the keyboard!");
inputText("\b\b\b"); -- delete backward for 3 characters 

fakeLocation(appIdentifier, latitude, longitude)

Fake geographic position for the specified apps, it remains in effect until you call clearFakeLocation, or clear the faking in the settings view.

fakeLocation("com.apple.Maps", 36, 50);  -- fake location for Apple Map. 

clearFakeLocation(appIdentifier)

Clear the location faking for one specified app.

clearFakeLocation("com.apple.Maps");  -- clear the location faking for Apple Map.

dialog(controls, enableRemember)

Show a dialog accepts user input.

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))

getOrientation()

Get the screen orientation.

local o = getOrientation();
      

3.3. Key Types
3.4. Dialog Control Types
3.5. Screen Orientation Types