A closer look at what ketec does on an iPhone: how it touches the screen, how it finds what it needs, how scripts run and how a whole fleet stays under control.
Switch the run mode in Settings. Your scripts and the API stay exactly the same.
Agent mode
No extra hardware
Uses the system automation service to deliver touches and read the UI tree on screen.
Taps, swipes, multi-finger gestures and W3C Actions
Reads the UI tree for node selectors
Needs Developer Mode and a one-time developer image activation
scriptiOS
HID mode
ESP32-S3 accessory
A small USB accessory running ketec firmware acts as a mouse and keyboard, so input arrives as genuine hardware events.
Hardware taps, swipes and key combinations
Absolute and homing pointer modes for different iOS versions
No developer image required
ESP32-S3USB HID
Agent vs HID at a glance
Capability
Agent
HID
Extra hardware
None
ESP32-S3 board on USB
Multi-finger gestures
Yes
Single pointer
UI tree and node selectors
Yes
Use image matching and OCR instead
Developer image
Required, one-time activation
Not required
Input
Gestures that feel human
From a single tap to a two-finger pinch, with randomness exactly where you want it.
Taps and swipes
click, doubleClick, swipe, swipeCurve and pressAndSwipe, with durations and an optional jitter radius.
Multi-finger gestures
Compose pinches, rotations and multi-taps with ActionBuilder, or send standard W3C Actions. Agent mode.
Text input
Type, paste, clear and read back text through the ketec keyboard extension, including long and non-Latin text.
Buttons and keys
Home, volume and app switcher buttons, plus key combinations such as select all, copy and paste in HID mode.
scripts/main.js
// A small random offset on every gesture
action.setJitterValue(4);
action.click(540, 1200);
action.doubleClick(540, 1200);
action.swipeCurve(200, 1600, 320, 1100, 200, 600, 400);
// Two-finger pinch out (Agent mode)
const b = action.createBuilder();
b.addPointer().moveTo(480, 1150).down().moveTo(330, 1000, 300).up();
b.addPointer().moveTo(600, 1250).down().moveTo(750, 1400, 300).up();
b.execute();
// Type through the ketec keyboard
if (ime.isOk()) ime.input("Hello from ketec");
Find on screen
Find it by text, by control or by pixels
Mix strategies in one script: start with a node selector, fall back to an image or OCR when an app draws its own UI.
-- 1. Node selector (Agent mode)
local sel <close> = node.createNodeSelector():label("Continue")
local btn = sel:getOneNodeInfo(3000)
if btn then btn:clickCenter() end
-- 2. Template matching on a fresh screenshot
local shot = image.captureScreen()
local tpl = image.readImage("res/badge.png")
local hits = image.findImage(shot, tpl, 0, 0, 0, 0, 0.9, 1)
if #hits > 0 then
action.click(hits[1].centerX, hits[1].centerY)
end
image.release(shot)
from ketec import node, image, action
# 1. Node selector (Agent mode)
sel = node.createNodeSelector().label("Continue")
btn = sel.getOneNodeInfo(3000)
if btn:
btn.clickCenter()
sel.releaseNode()
# 2. Template matching on a fresh screenshot
shot = image.captureScreen()
tpl = image.readImage("res/badge.png")
hits = image.findImage(shot, tpl, 0, 0, 0, 0, 0.9, 1)
if hits:
action.click(hits[0].centerX, hits[0].centerY)
image.release(shot)
Node selectors
Match controls by label, title, identifier, type, value or XPath, then tap the center, scroll into view or walk parents and siblings.
Image and color
Template matching, single and multi-point color search, color counting, binarization and QR or barcode scanning.
OpenCV inside
Around 140 OpenCV functions in JavaScript through the cv module, and the real cv2 package in Python.
Vision & AI
Recognition that runs on the phone
Several OCR engines, object detection and speech, all on the device. No license keys, no uploads.
PP-OCR
Chinese, English, Japanese, Korean and digits, with detection-only, recognition-only and character whitelist options.
Apple Vision OCR
The system text recognizer, available as a second engine next to PP-OCR.
More OCR options
A bundled open-model engine with tap-point helpers, plus dot-matrix OCR with custom fonts for pixel digits.
YOLO detection
Load your own YOLO detection and classification models and run them on the screen or any region.
Language models
Connect the LLM provider of your choice, then ask, judge, extract or chat from a script.
Text to speech
Speak status updates aloud with the system voices, wait for them to finish or stop at any time.
Scripting
Three languages, one API
Modules and function names are the same in JavaScript, Lua and Python, so a script ports in minutes.
JavaScript
The full module set, timers and the console. Every function also has a Chinese-named alias.
Lua 5.4
Global module tables, colon-style methods, cooperative coroutines and close-variable cleanup.
Python 3.14
CPython with requests, websockets, PyMySQL, numpy and opencv-python. Screen captures arrive as numpy arrays.
Lifecycle hooks
Stop and exception callbacks receive a status, so every run ends cleanly. Restart a script from inside itself.
Threads and shared state
Run work in parallel threads and share values between them safely, with batch updates.
Config pages and packages
Ship a web-based settings page with your script, install it as a package and push updates with hot update.
Device & system
Everything around the script
Launch apps, read the device state and keep your user informed while a script runs.
Apps and URLs
Start, stop and activate apps by bundle ID, list installed apps, read the foreground app and open URLs.
Device state
Battery, storage, memory, CPU, screen size, orientation, brightness, volume, lock state and LAN address.
Floating window
A picture-in-picture window shows live logs or your own text, and its play and pause buttons start and stop the script.
Media and feedback
Save images and videos to the photo library, play audio, vibrate, post notifications and show toasts or dialogs.
Data & network
Talk to the rest of your stack
Scripts can call APIs, keep sockets open, write to databases and work with files on the device.
HTTP and WebSocket
GET, POST, JSON, file downloads and WebSocket connections.
MySQL and SQLite
Queries, statements and transactions against a remote MySQL server or a local SQLite file.
Files and formats
Read and write files line by line, unzip and zip archives, edit plist files and keep script settings.
Crypto and utilities
AES and RSA, MD5 and SHA hashes, Base64 and hex helpers, random values and UUIDs.
scripts/main.js
// Report results to your own backend
const res = http.postJSON("https://example.com/api/runs", {
device: device.getDeviceName(),
battery: device.getBatteryInfo(),
});
logi("server said: " + res);
// Keep a history in MySQL
mysql.connect({ host: "db.example.com", username: "bot", password: "…", database: "farm" });
mysql.execute("INSERT INTO runs (device, ok) VALUES (?, ?)", [device.getDeviceName(), 1]);
mysql.disconnect();
Fleet & remote
From one phone to a rack of them
Every phone exposes an HTTP API on your network. Workbench, remote debugging and cloud control build on it.
terminal
# Every phone listens on port 9800
curl http://<iphone-ip>:9800/api/status
# Tap, swipe and take a screenshot
curl "http://<iphone-ip>:9800/api/control/click?x=540&y=1200"
curl -o shot.jpg http://<iphone-ip>:9800/api/screenshot
# Run a JavaScript snippet and get the result back
curl -X POST http://<iphone-ip>:9800/api/runScript \
-H "Content-Type: application/json" \
-d '{"script":"device.getOSVersion()"}'
LAN HTTP API
Port 9800 on each phone: taps and swipes, screenshots, an MJPEG screen stream, script runs, files, logs and the keyboard.
ketec Workbench
A device wall with live mirroring, group runs, a script editor, file browser, live logs and HID firmware flashing.
Remote debugging
Enter an 8-digit link code from Workbench and the phone joins over the ketec relay, or use your own server. Idle sessions disconnect automatically.
Cloud control
Phones connect out to your own server over WebSocket, take commands and report custom events from scripts.
The app
Clear on the phone, too
Four tabs cover everything an operator needs on the device itself.
01
Status
Run mode, Agent and HID state, address and port, screen recording and the current script.
02
Packages
Install, load, run and remove script packages.
03
UI
The settings page that ships with the current script.
04
Settings
Controls, run mode, network and services, keyboard and permissions, logs with keyword and level filters, English or Chinese interface.
Works with Shortcuts: bundled shortcut actions can launch ketec and run scripts.
Put your iPhones to work
Install ketec through TestFlight, write your first script in minutes and scale to a whole fleet when you are ready.