iOS Automation Framework iOS Touch Simulation Library
iOS Automation Framework iOS Touch Simulation Library
A system wide touch event simulation library for iOS 11.0 - 14.
Jailbroken device required. Application wide touch simulation library: PTFakeTouch. Choose as you like:)
Discord: https://discord.gg/acSXfyz
Please give me a star!
Read this in other languages(send email to me if you want to help to translate this page): 简体中文版说明文档
This library enables you to simulate touch events on iOS 11.0 - 14 with just one line of code! Currently, the repository is mainly for programmers. In the future, I will make it suitable for people who do not understand how to code.
I am a Computer Science student in University of Pittsburgh, and my spring 2021 term has started. My workload for this semester is pretty heavy. Although this semester is extremely boring because I didn't enroll in any of the CS courses this semester, I still have to focus on studying. So, I have to reduce the amount of time spending on updating ZXTouch. But I will still update it when I am free.
Submit suggestions on discord!
Remote Controlling: You can control your iOS device from local scripts, computers, or even other iOS devices! Instant Controlling: Here is a demo of PUBG Mobile. Recording & Playback: Record touch events and playback Demo #4: Activator Support
Demo #5: OCR
Demo #6: Touch Indicator
Demo #7: Text Input
Demo #8: Color Picker
See python version of documentation below. But you can also use ANY language to control your iOS device as long as the language supports socket. Here is how it works:
After installation, the tweak starts listening at port 6000.
To control your device, send data in certain format to port 6000 on your device. I will not list the detail format of data here, but you can read my python module source code to figure it out.
On Your iOS Device: ZXTouch python module will be automatically installed on your iOS device.
On Computers: If you want to install ZXTouch python module on your computer for remote controlling, download the source code from github and copy the zxtouch folder to your "site-packages" folder of your python on your computer.
To create a instance, use zxtouch(ip) where ip is the ip address of your device. If you want to run the script locally on your iOS device, just input "127.0.0.1".
from zxtouch.client import zxtouch # import module
device = zxtouch("127.0.0.1") # create instanceBring Application to Foreground
Color Picker (RGB Value From A Point on Screen)
There are two methods you can use to send touch events.
For a single touch event:
def touch(type, finger_index, x, y):
"""Perform a touch event
Args:
type: touch event type. For touch event types, please insert "from zxtouch.touchtypes import *" at top of your script.
finger_index: the finger index of the touch event. The range should be 1-19
x: x coordinate of the screen
y: y coordinate of the screen
Returns:
None
"""For sending multiple touch events at the same time:
def touch_with_list(self, touch_list: list):
"""Perform touch events with a list of events
touch list should be type of list. Inside the list, there must be dictionaries with the following format
Args:
touch_list: format example: [{"type": ?, "finger_index": ?, "x": ?, "y": ?}]
Returns:
None
"""Code Example
…def switch_to_app(bundle_identifier):
"""Bring an application to foreground
Args:
bundle_identifier: the bundle identifier of the application
Returns:
Result tuple
The format of the result tuple:
result_tuple[0]: True if no error happens when executing the command on your device. False otherwise
result_tuple[1]: error info if result_tuple[0] == False. Otherwise ""
"""Code Example
from zxtouch.client import zxtouch
device = zxtouch("127.0.0.1") # create instance
device.switch_to_app("com.apple.springboard") # return to home screen
device.disconnect()def show_alert_box(title, content, duration):
"""Show alert box on device
Args:
title: title of the alert box
content: content of the alert box
duration: the time the alert box shows before disappear
Returns:
Result tuple
The format of the result tuple:
result_tuple[0]: True if no error happens when executing the command on your device. False otherwise
result_tuple[1]: error info if result_tuple[0] == False. Otherwise ""
"""Code Example
from zxtouch.client import zxtouch
device = zxtouch("127.0.0.1") # create instance
device.show_alert_box("Alert", "This is a system-wide alert box that lasts for 3 seconds", 3)
device.disconnect()def run_shell_command(command):
"""Run shell command on device as root
Args:
command: command to run
Returns:
Result tuple
The format of the result tuple:
result_tuple[0]: True if no error happens when executing the command on your device. False otherwise
result_tuple[1]: error info if result_tuple[0] == False. Otherwise ""
"""Match screen with a template image.
…Code Example
……Code Example
…def pick_color(x, y):
"""Get the rgb value from the screen.
Args:
x: x coordinate of the point on the screen
y: y coordinate of the point on the screen
Returns:
Result tuple
The format of the result tuple:
result_tuple[0]: True if no error happens when executing the command on your device. False otherwise
result_tuple[1]: error info if result_tuple[0] == False. Otherwise a dictionary containing red, green, blue of the point on screen.
"""Code Example
from zxtouch.client import zxtouch
import time
device = zxtouch("127.0.0.1")
print("Picking color from 100, 100 after 1.5 seconds...")
time.sleep(1.5)
result_tuple = device.pick_color(100, 100)
if not result_tuple[0]:
print("Error while getting color. Error info: " + result_tuple[1])
else:
result_dict = result_tuple[1]
print("Red: " + result_dict["red"] + ". Green: " + result_dict["green"] + ". Blue: " + result_dict["blue"])
device.disconnect()I don't know the why, but if you call time.sleep in python, the sleep time will not be accurate. However you can use accurate_sleep method in zxtouch to sleep for an accurate time.
def accurate_usleep(microseconds):
"""Sleep for an accurate time
Args:
microseconds: microseconds to sleep
Returns:
Result tuple
The format of the result tuple:
result_tuple[0]: True if no error happens when executing the command on your device. False otherwise
result_tuple[1]: error info if result_tuple[0] == False. Otherwise ""
"""If the keyboard is showing, hide the keyboard
def hide_keyboard():
"""Hide the keyboard
Returns:
Result tuple
The format of the result tuple:
result_tuple[0]: True if no error happens when executing the command on your device. False otherwise
result_tuple[1]: error info if result_tuple[0] == False. Otherwise ""
"""If the keyboard is hiding, show the keyboard
def show_keyboard():
"""Show the keyboard
Returns:
Result tuple
The format of the result tuple:
result_tuple[0]: True if no error happens when executing the command on your device. False otherwise
result_tuple[1]: error info if result_tuple[0] == False. Otherwise ""
"""Insert text to the current text field. If you want to delete characters, please call this method like this: device.insert_text("\b")
def insert_text(text):
"""Insert text to the textfield
Args:
text: text to insert (\b for deleting characters)
Returns:
Result tuple
The format of the result tuple:
result_tuple[0]: True if no error happens when executing the command on your device. False otherwise
result_tuple[1]: error info if result_tuple[0] == False. Otherwise ""
"""Move the text cursor on textfield
def move_cursor(offset):
"""Move the cursor
Args:
offset: the related position you want to move. To move left, offset should be negative. For moving right, it should be positive
Returns:
Result tuple
The format of the result tuple:
result_tuple[0]: True if no error happens when executing the command on your device. False otherwise
result_tuple[1]: error info if result_tuple[0] == False. Otherwise ""
"""Play a zxtouch script on iOS device.
def play_script(script_absolute_path):
"""Play a zxtouch script on iOS device.
Args:
script_absolute_path: absolute path of the script
Returns:
Result tuple
The format of the result tuple:
result_tuple[0]: True if no error happens when executing the command on your device. False otherwise
result_tuple[1]: error info if result_tuple[0] == False. Otherwise ""
"""Force the device
No open issues yet, or sync has not completed.