Script API reference

45 modules, 621 functions. The same module and function names work in JavaScript, Lua and Python. Machine-readable version: /api/script-api.json.

ketec scripts can be written in JavaScript, Python or Lua. The three languages share the same modules, function names and parameter order; Python uses from ketec import action, image, ... (keyword arguments are supported) and some lower-case module names (appleocr, paddleocr, tomatoocr, dotocr, netcard, hotupdate, yolocls); in Lua modules are global tables and object methods use a colon (selector:getOneNodeInfo()). Coordinates for action/hid/image/OCR are screen pixels (see device.getScreenRealSize(), e.g. 1170x2532 on a 3x iPhone); node bounds are logical points. Run modes: Agent mode (developer disk image mounted, Agent connected) synthesizes touches and text on the device and supports node trees and w3cActions; HID mode drives an external ESP32 USB HID device, needs the screen broadcast for screenshots/OCR, and has no node tree or w3cActions. action.* follows the current mode automatically; hid.* always uses the HID device. Relative file paths resolve to the app Documents folder. Each function has a status: stable = works as described; limited = works with the restriction stated in its description; unsupported = present but returns a fixed failure value. Functions marked ketec_extra are ketec additions beyond the common signature set. Defaults shown are those of the current implementation. Many functions also have Chinese-named aliases; this reference lists the English names. JavaScript snippets can be tried with POST /api/runScript on the device HTTP service (default port 9800, e.g. http://phone-ip:9800); the value of the last expression is returned.

action — Touch & input

High-level touch, swipe and text input. Each call is routed by the current run mode: in Agent mode events are synthesized by the on-device Agent; in HID mode they go through the external HID device. Coordinates are screen pixels (e.g. 1170x2532 on a 3x device).

Modes: agent, hid

action.click(x, y, duration?, jitter?)

Taps a point.

action.click(540, 1200);

action.clickRandom(x1, y1, x2, y2, duration?)

Taps a random point inside the rectangle. An invalid rectangle (x2<=x1 or y2<=y1) falls back to the whole screen.

action.doubleClick(x, y, duration?, interval?, jitter?)

Double-taps a point.

action.doubleClickRandom(x1, y1, x2, y2, duration?, interval?)

Double-taps a random point inside the rectangle (invalid rectangle = whole screen).

action.swipe(startX, startY, endX, endY, duration?, jitter?, steps?)

Swipes in a straight line. In HID mode jitter and steps are ignored.

action.swipe(540, 1800, 540, 600, 300);

action.pressAndSwipe(startX, startY, endX, endY, touch_down_duration?, touch_move_duration?)

Long-press then move to the end point. HID mode: real press-drag-release. Agent mode: a long press followed by a separate swipe (finger is lifted in between), so it may not drag items; use action.drag for a held drag. Extra parameters from the signature table (touch_up_duration, jitter, steps) are ignored. [limited]

action.swipeCurve(startX, startY, midX, midY, endX, endY, duration?)

Swipes through a middle point. Implemented as two straight segments (start→mid, mid→end) by the Agent synthesizer; for a curved HID swipe use hid.swipeCurve. [limited]

action.input(text, frequency?)

Types text into the focused field. Agent mode types through the Agent (fast); in HID mode with the HID device connected it is sent through HID. If the Agent path fails it falls back to HID.

action.input('hello 你好');

action.inputSimple(text)

Types text key by key (about 15 chars/s in Agent mode). In HID mode, if the ketec keyboard is on screen the text is inserted through it, otherwise sent as HID keystrokes (ASCII only).

action.backspace(count?)

Deletes characters before the cursor.

action.enter()

Presses Return.

action.homeScreen()

Goes to the Home Screen. Only works through HID; in Agent mode it returns false. [limited]

action.pressButton(button)

Presses a device/media button through the HID device. Requires a connected HID device in any mode; otherwise returns false. [limited]

action.sendKey(keys)

Sends a key combination through the HID device. Requires a connected HID device. [limited]

action.sendKey([hidKey.COMMAND, 'a']);

action.w3cActions(json)

Runs a W3C Actions gesture sequence (multi-touch, holds, sequences). Agent mode only; returns false in HID mode or for an empty body.

action.createBuilder()

Creates a gesture builder. Pointers added in one group run in parallel (pinch/rotate); groups and singleTap/multiTap run in call order. Executes through w3cActions, so Agent mode only.

action.createBuilder().addPointer().moveTo(300,800).down().moveTo(300,400,300).up().done().execute();

action.setJitterValue(value)

Sets the random jitter amplitude for Agent taps/swipes.

action.getRunMode()

Returns the current run mode.

action.longPress(x, y, duration?)

Long-presses a point and returns after the hold time.

action.drag(x1, y1, x2, y2, duration?)

Press-hold-drag with the finger kept down. Agent mode only (returns false in HID mode).

action.findText(text, options?)

Screenshots and OCRs the screen, returning the best match for the text.

action.clickText(text, options?)

Finds text on screen with OCR and taps its center.

node — UI element tree

Find and operate UI elements of the foreground app via the accessibility snapshot. Entry point: createNodeSelector(). Requires Agent mode (developer image mounted, Agent connected). NodeInfo.bounds are in logical points (multiply by device.getScreenScale() before passing to action.click); NodeInfo action methods convert automatically.

Modes: agent

createNodeSelector(params?)

Creates a node selector. Add conditions (all must match), then call getNodeInfo / getOneNodeInfo.

var n = createNodeSelector().label('Settings').getOneNodeInfo(3000); if (n) n.tap();

selector.label(value)

Matches label exactly.

selector.labelMatch(pattern)

Matches label with a regular expression.

selector.title(value)

Matches title exactly.

selector.titleMatch(pattern)

Matches title with a regular expression.

selector.identifier(value)

Matches accessibility identifier exactly.

selector.identifierMatch(pattern)

Matches identifier with a regular expression.

selector.value(value)

Matches value exactly.

selector.valueMatch(pattern)

Matches value with a regular expression.

selector.placeholderValue(value)

Matches placeholder text exactly.

selector.placeholderValueMatch(pattern)

Matches placeholder with a regular expression.

selector.type(value)

Matches element type; use the full name, e.g. "XCUIElementTypeButton".

selector.typeMatch(pattern)

Matches type with a regular expression.

selector.enabled(flag)

Matches enabled state.

selector.index(n)

Matches sibling index.

selector.depth(n)

Matches tree depth.

selector.childCount(n)

Matches child count.

selector.bounds(x, y, width, height)

Matches by element frame.

selector.xpath(expr)

Matches elements by XPath.

selector.id(nodeId)

Matches a node id.

selector.getNodeInfo(timeout?)

Returns all matching nodes.

selector.getOneNodeInfo(timeout?)

Returns the first matching node.

selector.loadNode(timeout?)

Forces a fresh snapshot of the element tree.

selector.releaseNode()

Releases the cached tree.

selector.clearSelector()

Clears all conditions.

selector.xml(timeout?)

Returns the whole element tree as XML.

node.id / label / type / value / title / identifier / placeholderValue / enabled / bounds / depth / index / parentId / childCount

Plain data properties of a NodeInfo.

node.tap()

Taps the element.

node.doubleTap()

Double-taps the element.

node.press(duration?)

Long-presses the element.

node.clickCenter()

Taps the element center.

node.clickRandom()

Taps a random point inside the element.

node.hittable()

Whether the element can receive a tap.

node.scrollToVisible()

Scrolls until the element is visible.

node.input(text)

Focuses the element and types text.

node.clearInput()

Clears the text field.

node.setValue(text)

Sets the element value.

node.parent() / child(i) / allChildren() / siblings() / previousSiblings() / nextSiblings()

Tree navigation helpers.

node.isAvailable()

Whether the element-tree engine is usable now.

node.xml(timeout?)

Shortcut for createNodeSelector().xml().

node.refresh()

Drops the cached tree so the next query re-snapshots.

node.lastError()

Returns the last node error code (e.g. node_unavailable).

node.lastResult()

Structured receipt of the last node action.

image — Screenshots & image matching

Capture the screen and work with images by imageId (string handle). Includes color finding, multi-point color, template matching (OpenCV), cropping, saving and QR/barcode scanning. Coordinates are image pixels; full-screen captures equal screen pixels. In HID mode screenshots come from the screen broadcast, which must be running. Release images you no longer need.

Modes: agent, hid

image.captureScreen(x?, y?, ex?, ey?)

Takes a screenshot, optionally cropped to (x, y)–(ex, ey).

var img = image.captureScreen(); /* ... */ image.release(img);

image.captureFullScreen()

Takes a full-screen screenshot.

image.captureRect(x, y, width, height)

Takes a screenshot of a rectangle given as x, y, width, height.

image.setCaptureImageId(imageId)

Sets the capture source used by captureScreen. Only "screen" produces frames in this build; other sources make captures return undefined. Empty string = no change. [limited]

image.captureMat()

Python only: screenshot as an OpenCV/numpy BGR array.

image.readImage(path)

Loads an image file into a new imageId.

image.readImageMat(path)

Python only: reads an image file as a BGR array.

image.imageIdToMat(imageId)

Python only: converts an imageId to a BGR array.

image.clip(id, x, y, ex, ey)

Crops an image to a new imageId.

image.getSize(id)

Returns image size.

image.toBase64Format(id, format?, q?)

Encodes an image as Base64.

image.base64ToImage(base64data)

Decodes Base64 into a new imageId.

image.isRelease(id)

Whether an imageId has been released.

image.release(id)

Releases an image.

image.releaseAll()

Releases all images.

image.saveTo(id, path)

Saves an image to a file (parent folders are created).

image.rotateImage(id, degree)

Rotates an image by a multiple of 90°.

image.cmpColor(id, points, threshold?)

Multi-point color compare at fixed positions.

image.findColor(id, color, threshold?, x?, y?, ex?, ey?, limit?, orz?)

Finds pixels of a color in a region.

var pts = image.findColor(img, '#FF3B30', 0.95, 0, 0, 0, 0, 1);

image.findMultiColor(id, firstColor, threshold?, points, x?, y?, ex?, ey?, limit?, orz?)

Multi-point color search: finds anchor positions where all offset points also match.

image.countColor(id, colors, threshold?, x?, y?, ex?, ey?)

Counts pixels matching the color(s).

image.findImage(id, templateImageId, x?, y?, ex?, ey?, threshold?, limit?, method?, rgb?, options?)

Template matching with OpenCV. Methods 1/3/5 are the reference path; method 99 picks scales differently for limit>1 and method 0 confidence is inlier ratio — use top-1 / position only. Flat (texture-less) templates give meaningless hits.

var r = image.findImage(img, tpl, 0, 0, 0, 0, 0.9, 1); if (r.length) action.click(r[0].centerX, r[0].centerY);

image.findImageEx(id, kjstPath)

Not supported: the template-project file format is not implemented; always returns []. [unsupported]

image.pixel(id, x, y)

Reads one pixel color.

image.argb(color)

Converts an ARGB integer to a hex color string.

image.binaryzation(id, threshold?)

Black/white thresholding into a new image.

image.gray(id)

Grayscale copy of an image.

image.scanCode(id)

Scans a QR code or barcode in the image.

image.drawRect(id, x, y, ex, ey, color?, thickness?)

Draws a rectangle onto the image in place.

appleOcr — Apple Vision OCR

Text recognition with the system Vision framework. No model download needed. The region filters lines that intersect it; returned coordinates are absolute.

Modes: agent, hid

appleOcr.recognizeAbs(input?, x?, y?, ex?, ey?, languages?)

Recognizes all text lines.

var lines = appleOcr.recognizeAbs('screen');

appleOcr.recognizeNumbersAbs(input?, x?, y?, ex?, ey?)

Fast recognition keeping only lines made of digits.

appleOcr.findTextAbs(input, texts, x?, y?, ex?, ey?, languages?, exactMatch?)

Recognizes and keeps only lines matching any of the texts.

var r = appleOcr.findTextAbs('screen', ['Settings']); if (r.length) action.click(r[0].centerX, r[0].centerY);

appleOcr.recognize(input?)

Full-image recognition (shortcut).

appleOcr.findText(input, texts, exactMatch?)

Full-image findTextAbs.

appleOcr.recognizeNumbers(input?, x?, y?, ex?, ey?)

Same as recognizeNumbersAbs.

paddleOcr — PaddleOCR (on-device)

PP-OCR models running on-device with ncnn, bundled in the app. The default model (ppocr-v6-small) loads automatically on first use. *Abs functions return coordinates in the full image; recognize/findText return coordinates relative to the region.

Modes: agent, hid

paddleOcr.loadModel(modelId, useGpu?)

Loads (or switches to) a bundled model.

paddleOcr.setMaxSideLen(maxSideLen?)

Sets the detection input size.

paddleOcr.recognizeAbs(input?, x?, y?, ex?, ey?, confidenceThreshold?)

Recognizes text, absolute coordinates.

var r = paddleOcr.recognizeAbs('screen');

paddleOcr.findTextAbs(input, targetTexts, x?, y?, ex?, ey?, confidenceThreshold?, exactMatch?)

Finds target texts, absolute coordinates.

paddleOcr.free()

Unloads the model.

paddleOcr.recognize(input?, x?, y?, ex?, ey?, confidenceThreshold?)

Like recognizeAbs but coordinates are relative to the region.

paddleOcr.findText(input, targetTexts, x?, y?, ex?, ey?, confidenceThreshold?, exactMatch?)

Like findTextAbs with region-relative coordinates.

paddleOcr.loadV5(useGpu?)

Shortcut for loadModel("ppocr-v5").

tomatoOcr — tomatoOcr-compatible OCR

Compatibility interface for scripts written against the tomatoOcr API. ketec does not ship that third-party SDK; the same calls run on the bundled open-source PP-OCRv5/v6 models (ncnn). No license key is required.

Modes: agent, hid

tomatoOcr.initializeWithConfig(mode, licenseData, remark?)

Always succeeds; reports that the built-in open-source engine is used.

tomatoOcr.setHttpIntervalTime(value)

No effect (no online licensing)

tomatoOcr.setRecType(value)

Model group: "ch-3.0" (default) / "ch-2.0" / "ch" → PP-OCRv6; "cht" / "japan" → PP-OCRv5; "korean"; "number" (digits only)

tomatoOcr.setDetBoxType(value)

"rect" (default) or "quad" box output

tomatoOcr.setDetUnclipRatio(value)

Detection box expansion (default 1.9)

tomatoOcr.setDetScaleRatio(value)

Detection scale factor (default 1.0)

tomatoOcr.setRecScoreThreshold(value)

Minimum recognition score (default 0.1)

tomatoOcr.setReturnType(value)

"json" (default), "text", "num", or a custom character set to keep

tomatoOcr.setBinaryThresh(value)

Binarize before OCR (0–255, 0 = off)

tomatoOcr.setRunMode(value)

Recorded only; a single CPU engine is used

tomatoOcr.setFilterColor(filterColor, backgroundColor)

Keeps only pixels of the given colors before OCR.

tomatoOcr.ocrImage(input, type?, x?, y?, ex?, ey?)

Runs OCR and returns a string.

tomatoOcr.findTapPoint(data)

Looks up a tap point in the last OCR result.

tomatoOcr.findTapPoints(data)

All matching tap points from the last OCR result.

tomatoOcr.release()

Unloads the model and clears the last result.

dotOcr — Dot-matrix font OCR

Recognizes fixed bitmap fonts (game digits, LED text) with a JSON glyph library. Font files must use format "ketec-dot-font" (a compatible third-party format name is also accepted).

Modes: agent, hid

dotOcr.loadFont(fontPath)

Loads a glyph library.

dotOcr.free(fontId)

Unloads one font.

dotOcr.freeAll()

Unloads all fonts.

dotOcr.recognizeAbs(fontId, input, x?, y?, ex?, ey?, confidenceThreshold?)

Recognizes characters, absolute coordinates.

dotOcr.findTextAbs(fontId, input, targetTexts, x?, y?, ex?, ey?, confidenceThreshold?, exactMatch?)

Finds target texts.

app — Apps (ketec helper)

Small ketec helper module for launching/terminating apps and reading the app list. JavaScript (and dynamic lookup) only; the system module offers the same features with the standard names.

Modes: agent, hid

app.list()

Installed apps.

app.frontmost()

Foreground app.

app.launch(bundleId)

Launches / brings an app to the front.

app.terminate(bundleId)

Terminates an app (through the Agent).

system — System & apps

App launch/stop, foreground and installed app info, clipboard, URL opening, notifications, lock state, memory and CPU.

Modes: agent, hid

system.startApp(bundle_id)

Launches an app (or brings it to the front).

system.startApp('com.apple.calculator');

system.stopApp(bundle_id)

Terminates an app through the Agent. In HID mode use hid.closeApp, which can close apps with a gesture.

system.activateApp(bundle_id)

Brings an app to the front (same as startApp).

system.activateAppInfo()

Current foreground app.

system.foregroundAppInfos()

Foreground app as a list.

system.backgroundAppInfos()

Background apps from the process list. The iOS sandbox usually hides other processes, so this is often []. [limited]

system.getInstalledAppList()

Installed apps.

system.recent()

Not implemented in the script binding (returns undefined). Use hid.recent() in HID mode. [unsupported]

system.openURL(url)

Opens a URL from inside ketec. Some schemes (e.g. prefs:) or opening while ketec is in background may not work; in HID mode hid.openURL is more reliable. [limited]

system.notify(msg, title?, id?)

Posts a local notification (asks for permission the first time; also shown while ketec is in front).

system.setClipboard(text)

Writes the clipboard.

system.getClipboard()

Reads the clipboard.

system.isLocked()

Whether the device is locked.

system.lock()

Locks the screen via the HID power key. Requires a connected HID device. [limited]

system.unlock()

Wakes the screen via HID (presses Home twice); does not enter a passcode. Requires HID. [limited]

system.getMemoryInfo()

Memory statistics.

system.getUsedMemory()

Used memory (MB, system-wide).

system.getAvailableMemory()

Available memory (MB).

system.getTotalMemory()

Total physical memory (MB).

system.getSystemUsedMemory()

Currently returns the same value as getUsedMemory (the separate systemUsed figure is in getMemoryInfo()). [limited]

system.getCpuUsage()

CPU usage of the ketec process (all threads).

system.startAgent()

Not implemented: ketec has no separate Agent service to start from scripts. [unsupported]

system.stopAgent()

Not implemented (see startAgent). [unsupported]

system.getAgentStatus()

Whether the Agent channel is connected.

system.uptime()

System uptime.

device — Device info

Device identity, screen, battery, storage, volume, brightness, orientation, network address and vibration.

Modes: agent, hid

device.getBatteryInfo()

Battery level and charging state.

device.getStorageSpace()

Storage capacity.

device.getDeviceID()

ketec device identifier.

device.getECID()

Device ECID.

device.getUDID()

Device UDID.

device.getDeviceName()

Device name.

device.getDeviceModel()

Device model.

device.getScreenRealSize()

Screen size in pixels (the coordinate space for action/hid).

device.getScreenSize()

Screen size in points.

device.getScreenScale()

Pixels per point.

device.getScreenBrightness()

Screen brightness.

device.setScreenBrightness(brightness)

Sets screen brightness.

device.getVolume()

Media volume.

device.setVolume(volume)

Sets media volume.

device.getOrientation()

Screen orientation.

device.getOSVersion()

iOS version.

device.getLanIp()

Local network address of the device.

device.vibrate(duration?, intensity?)

Vibrates with Core Haptics (falls back to the system vibration).

device.getServerDeviceId()

Device id assigned by the ketec service.

hid — HID device (ESP32)

Direct control through the external USB HID device (ESP32-S3 firmware): absolute pointer taps/swipes, keyboard keys, media buttons and system shortcuts. Works without the Agent. Coordinates are screen pixels. Key-code constants are available as hidKey (e.g. hidKey.COMMAND, hidKey.RETURN, hidKey.A).

Modes: hid

hid.openRecordScreen()

Shows the system screen-broadcast picker (needed for screenshots/OCR in HID mode).

hid.isRecording()

Whether screen capture is running.

hid.isBLEConnected()

Bluetooth HID is not supported (USB firmware only); always false. [unsupported]

hid.isUSBConnected()

Whether the USB HID device is connected.

hid.getBLEHIDDeviceName()

Bluetooth HID not supported; returns "". [unsupported]

hid.setBLEHIDDeviceName(name)

Bluetooth HID not supported; returns false. [unsupported]

hid.getDeviceMac()

HID device MAC address.

hid.getDeviceModel()

HID device model.

hid.getDeviceVersion()

HID firmware version.

hid.resetPosition()

Re-sends screen size and coordinate mode to the firmware (re-calibrates the pointer).

hid.restartDevice()

Restarts the HID device; it reconnects in about a second.

hid.setCharging(on)

Not supported by the firmware; returns false. [unsupported]

hid.setJitterValue(value)

Same as action.setJitterValue; affects Agent-synthesized gestures only (HID taps have no jitter). [limited]

hid.setActionDelay(milliseconds)

Sets the firmware delay between actions.

hid.setMoveDelay(milliseconds)

Sets the firmware pointer-move delay.

hid.move(x, y)

Moves the pointer without pressing.

hid.click(x, y, duration?, jitter?)

Taps a point.

hid.click(540, 1200);

hid.mouseDown()

Presses and holds the pointer button at the current position.

hid.mouseUp()

Releases the pointer button.

hid.clickRandom(x1, y1, x2, y2, duration?)

Taps a random point inside the rectangle.

hid.doubleClick(x, y, duration?, interval?, jitter?)

Double-taps a point.

hid.doubleClickRandom(x1, y1, x2, y2, duration?, interval?)

Double-taps a random point inside the rectangle.

hid.swipe(x, y, ex, ey, jitter?, steps?)

Straight swipe (about 300 ms). A number as the 5th argument is taken as the duration in ms.

hid.swipeCurve(startX, startY, midX, midY, endX, endY)

Swipes along a quadratic curve through the control point.

hid.pressAndSwipe(startX, startY, endX, endY, duration?)

Press, hold, drag to the end point and release. iOS may only enter jiggle mode on the first try when dragging Home Screen icons. [limited]

hid.homeScreen()

Goes to the Home Screen (requires HID run mode).

hid.input(text, frequency?)

Types text. Uses the ketec keyboard when it is on screen (recommended for Chinese/symbols), otherwise clipboard/HID fallbacks.

hid.inputSimple(text)

Types text key by key (same as action.inputSimple).

hid.space()

Types a space.

hid.backspace(count?)

Presses Backspace.

hid.enter()

Presses Return.

hid.sendKey(keys)

Sends a key combination. Modifier shortcuts inside text fields may not work without a software keyboard (iOS limitation); system shortcuts such as Cmd+H / Cmd+Space work.

hid.sendKey([hidKey.COMMAND, 'h']);

hid.pressButton(button)

Presses a media/system button.

hid.copyText()

Sends Cmd+C. May have no effect in text fields without a software keyboard. [limited]

hid.pasteText()

Sends Cmd+V. Same limitation as copyText. [limited]

hid.back()

Sends Tab+B ("back" in iOS Full Keyboard Access); only works when that accessibility feature is enabled. [limited]

hid.recent()

Opens the App Switcher (double Home).

hid.lock()

Locks the screen.

hid.unlock()

Wakes the screen (presses Home twice); does not enter a passcode.

hid.openURL(url)

Opens a URL through the ketec Shortcuts helper, falling back to opening locally; works while ketec is in background.

hid.openApp(name)

Launches an app by bundle id.

hid.closeApp(name)

Closes an app; in HID mode this is done with an App Switcher gesture (takes a few seconds).

hid.takeMeToFront()

Brings ketec to the front.

hid.currentAppInfo()

Foreground app; usually undefined in HID mode because there is no foreground-app source without the Agent. [limited]

hid.setClipboard(text)

Writes the clipboard.

hid.getClipboard()

Reads the clipboard.

hid.isConnected()

Same as isUSBConnected.

ime — ketec keyboard

Text operations through the ketec keyboard extension. Most functions require the ketec keyboard to be the active keyboard and visible; when it is not, some fall back to Agent/HID key events.

Modes: agent, hid

ime.isOk()

Checks that the keyboard is ready.

ime.getText()

Reads the text of the focused field.

ime.clearText()

Clears the focused field.

ime.input(text, frequency?)

Inserts text through the keyboard (HID fallback when the keyboard is not visible).

if (ime.isOk()) ime.input('你好');

ime.paste(text?)

Pastes text into the focused field.

ime.pressDel()

Deletes one character (Agent key event, or HID in HID mode).

ime.pressEnter()

Presses Return (Agent or HID).

ime.dismiss()

Hides the keyboard.

ime.getClipboard()

Reads the clipboard.

ime.setClipboard(text)

Writes the clipboard.

ime.switchKeyboard()

Switches to the next input method (keyboard globe action, or Ctrl+Space via HID).

http — HTTP client

Synchronous HTTP requests and file download. Available in JavaScript and Lua; in Python use the bundled requests / urllib instead.

Modes: agent, hid

http.httpGet(url, timeout?)

GET request.

var r = http.httpGet('https://example.com'); logi(r.status);

http.httpPost(url, body, timeout?)

POST request with a string body.

http.postJSON(url, data, timeout?)

POST a JSON body.

http.request(options)

Full-featured request. Redirects are always followed. A legacy form request(method, url, body, timeout) is also accepted.

http.downloadFile(url, path, timeout?, headers?)

Downloads to a file (2xx only).

http.newWebsocket(url)

Opens a WebSocket client. Sending works, but the on* callbacks are never invoked and heartbeat/timeout/auto-reconnect setters are no-ops, so incoming messages cannot be read. [limited]

file — Files

File and folder operations. Relative paths (and paths starting with "Documents/") resolve under the app Documents folder; absolute paths must be inside the app sandbox; ".." is rejected.

Modes: agent, hid

file.getInternalDir(type?)

Returns an app directory path.

file.create(path)

Creates an empty file (true if it already exists).

file.mkdirs(path)

Creates a directory with parents.

file.deleteAllFile(path)

Deletes a file or a whole directory.

file.readFile(path)

Reads a text file.

file.readResFile(fileName)

Not supported: there is no project resource directory; place files under Documents and use readFile. [unsupported]

file.getResFile(fileName)

Not supported (see readResFile). [unsupported]

file.cleanupResFile(path)

Not supported (see readResFile). [unsupported]

file.deleteLine(path, line, contains?)

Deletes lines from a text file.

file.listDir(path, recursion?)

Lists a directory.

file.writeFile(path, data)

Writes a text file (creates parent folders).

file.appendLine(path, data)

Appends data plus a newline (no newline is inserted before it if the file does not end with one).

file.readLine(path, lineNo)

Reads one line.

file.readAllLines(path)

Reads all lines.

file.exists(path)

Checks whether a path exists.

file.copy(src, dest)

Copies a file or folder.

file.fileMD5(path)

MD5 of a file.

config — Script config

Persistent key/value configuration for the current script package (the same store the package UI page reads and writes). Values keep their JSON type.

Modes: agent, hid

config.all()

Returns all config values.

config.setAll(config)

Writes several values.

config.set(key, value)

Sets one value.

config.get(key)

Reads one value.

var n = config.get('loops') || 10;

config.remove(key)

Removes a key.

sharedState — Shared state

In-memory key/value store shared by all scripts and threads in the ketec process (useful for communication with thread.run workers). Not persisted across app restarts.

Modes: agent, hid

sharedState.set(key, value)

Sets a value.

sharedState.get(key)

Reads a value.

sharedState.withBatch(block)

Runs a function, or sets every key of an object.

sharedState.clear()

Removes all keys.

plist — Property lists

Read and modify .plist files. Paths follow the file-module rules.

Modes: agent, hid

plist.read(path)

Reads a plist file.

plist.write(path, value, format?)

Writes a plist file.

plist.get(path, key)

Reads a (nested) key.

plist.set(path, key, value)

Sets a (nested) key, creating the file/dictionaries if needed.

plist.remove(path, key)

Removes one key (never deletes the file).

sqlite — SQLite

Local SQLite databases. open() returns a string handle used by the other functions.

Modes: agent, hid

sqlite.open(path)

Opens (or creates) a database.

var db = sqlite.open('data.db'); sqlite.execute(db, 'CREATE TABLE IF NOT EXISTS t(a TEXT)');

sqlite.close(handle)

Closes the database.

sqlite.isOpen(handle)

Whether the handle is open.

sqlite.query(handle, sql, params?)

Runs a query and returns rows.

sqlite.execute(handle, sql, params?)

Executes a statement.

sqlite.beginTransaction(handle)

BEGIN.

sqlite.commit(handle)

COMMIT.

sqlite.rollback(handle)

ROLLBACK.

mysql — MySQL client

Built-in MySQL client with one global connection shared by all scripts. Value mapping: integers come back as strings, DATE/DATETIME as ISO-8601 strings, DECIMAL/DOUBLE as numbers, TIME/JSON as null.

Modes: agent, hid

mysql.connect(config)

Connects (replacing any previous connection).

mysql.disconnect()

Closes the connection.

mysql.isConnected()

Connection state.

mysql.query(sql, params?)

Runs a query.

mysql.execute(sql, params?)

Executes a statement.

mysql.beginTransaction()

START TRANSACTION.

mysql.commit()

COMMIT.

mysql.rollback()

ROLLBACK.

zipFile — ZIP archives

Create and extract ZIP files. Paths follow the file-module rules.

Modes: agent, hid

zipFile.getFileList(path)

Lists entries of a ZIP.

zipFile.isZip(path)

Checks whether a file is a ZIP.

zipFile.unzip(zipPath, destDir)

Extracts a ZIP (entries containing ".." are skipped).

zipFile.zip(dirPath, zipPath)

Compresses a folder or file.

zipFile.zip('logs', 'out/logs.zip');

media — Photos & audio

Save to / clean the photo library and play MP3 files. Photo-library access permission is requested when needed.

Modes: agent, hid

media.saveImageToAlbum(imageId)

Saves an image to Photos.

media.saveVideoToAlbumPath(path)

Saves a video file to Photos.

media.deleteAllPhotos()

Deletes all photos. Returns immediately; iOS then asks the user to confirm.

media.deleteAllVideos()

Deletes all videos (iOS asks for confirmation).

media.deleteAllScreenshotAssets()

Deletes all screenshots (iOS asks for confirmation).

media.playMp3(path, loop?)

Starts playing an audio file (non-blocking).

media.stopMp3()

Stops playback.

media.playMp3WaitEnd(path)

Plays and blocks until finished.

media.isMp3Playing()

Whether audio is playing.

media.deleteAllScreenshots()

Same as deleteAllScreenshotAssets.

utils — Utilities

Time formatting, random numbers, UUID, Base64/hex conversion, bring ketec to front.

Modes: agent, hid

utils.timeFormat(format?)

Formats the current time.

utils.timeFormat('yyyyMMdd-HHmmss');

utils.random(min, max)

Random integer in [min, max].

utils.takeMeToFront()

Brings ketec to the foreground (asynchronous).

utils.randomUUID()

Random UUID string.

utils.hexString(source)

Text to hex.

utils.base64Encoded(source)

Base64-encodes UTF-8 text.

utils.base64Decoded(source)

Base64 to text.

utils.hexStringBase64Encoded(hexString)

Hex bytes to Base64.

utils.hexStringBase64Decoded(base64HexString)

Base64 to hex bytes.

utils.formatDate(timestamp?, format?)

Formats a timestamp.

cryptoUtils — Crypto

Hashes/HMAC, AES-ECB and RSA (PKCS#1 v1.5).

Modes: agent, hid

cryptoUtils.encryptWithAES_ECB(data, aesKey, noPadding?)

AES-ECB encryption.

cryptoUtils.decryptWithAES_ECB(data, aesKey, noPadding?)

AES-ECB decryption.

cryptoUtils.encryptWithRSA(data, publicKeyBase64)

RSA encryption (PKCS#1 v1.5).

cryptoUtils.decryptWithRSA(encryptedData, privateKeyBase64)

RSA decryption.

cryptoUtils.md5(source)

MD5 digest.

cryptoUtils.sha1(source, key?)

SHA-1 or HMAC-SHA1.

cryptoUtils.sha256(source, key?)

SHA-256 or HMAC-SHA256.

logger — Logging

Write log lines. In a running script package lines go to the ketec run log (visible in the app and via the log endpoints).

Modes: agent, hid

logger.debug(args)

Debug-level log.

logger.info(args)

Info-level log.

logger.info('step 1 done');

logger.warn(args)

Warning-level log.

logger.error(args)

Error-level log.

logger.setLoggerLevel(level)

Stores the minimum log level [effect on output unverified]. [limited]

logger.setLogToFile(enabled)

Stores the log-to-file preference [effect unverified]. [limited]

logger.setMaxLogFileCount(count)

Stores the max log file count [effect unverified]. [limited]

logger.setMaxLogFileSize(size)

Stores the max log file size [effect unverified]. [limited]

logger.resetLogFile()

Deletes the script log file.

g — Globals & run control

Script-wide functions. JavaScript: global functions (sleep, time, exit, logi/logw/loge/logd, createNodeSelector, setStopCallback ...). Python: from ketec import g (g.setStopCallback(...), constants g.runMode, g.appVersion, g.appName, g.appBundleId, g.appBuildNumber, g.isDebug, g.platform, g.packageJson, g.startParams; use time.sleep). Lua: capitalized globals Sleep, Exit, Time, TakeMeToFront, SetStopCallback, RestartScript, StartThread/StopThread, ToJsonString, constants RunMode, AppVersion, PackageJson, StartParams ...

Modes: agent, hid

takeMeToFront()

Brings ketec to the foreground.

setAgentTouchMode(mode)

Stores the Agent touch mode. In the current build the value is saved and returned but does not change how taps are synthesized. [limited]

getAgentTouchMode()

Reads the stored Agent touch mode.

setCpuAutoThrottle(enabled)

Stores the CPU auto-throttle switch. Saved only; no throttling is applied in the current build. [limited]

getCpuAutoThrottle()

Reads the stored switch.

setCpuThrottleDelay(min_ms, max_ms)

Stores the throttle delay range (saved only). [limited]

getCpuThrottleDelay()

Reads the stored delay range.

restartScript(delay_ms?)

Ends the current run and restarts the package script.

setStopCallback(callback)

Registers a stop callback (package runs).

setStopCallback(function(status){ logi('stopped: ' + status); });

setExceptionCallback(callback)

Registers an uncaught-exception callback (package runs).

sleep(ms)

Pauses the script (JavaScript; Lua: Sleep; Python: time.sleep).

sleep(500);

time()

Current timestamp in ms (Lua: Time).

exit()

Ends the script normally (Lua: Exit; Python: sys.exit).

logi(msg) / logw(msg) / loge(msg) / logd(msg)

Writes an info/warn/error/debug line to the run log (console.log maps to info).

println(value)

No-op kept for compatibility; returns null and writes nothing (use logi). [limited]

setTimeout(fn, ms) / setInterval(fn, ms) / clearTimeout(id) / clearInterval(id)

Timers return a handle but the callback is never executed (no event loop); use sleep() in a loop instead. [limited]

ui — Dialogs & package UI

Toasts and dialogs shown inside the ketec app, plus messaging with the package UI page. Dialogs need ketec in the foreground.

Modes: agent, hid

ui.show(text?)

Shows a simple translucent text panel over the ketec window. It does not open the package UI page. [limited]

ui.hide()

Removes the panel shown by ui.show.

ui.showToast(message)

Shows a short toast in the ketec window (visible only when ketec is in front).

ui.confirm(title, message)

Shows an OK/Cancel dialog and waits for the user.

ui.confirmInput(title, message, defaultInput?)

Shows a text-input dialog and waits.

ui.alert(title, message)

Shows an alert; returns immediately without waiting.

ui.onEvent(eventName, callback)

Listens for events emitted by the package UI page while the script runs (delivered during sleep()). Note: the current binding takes (eventName, callback), not a single callback.

ui.call(key, data?)

Calls a function registered by the package UI page (package runs; fire-and-forget).

ui.callFloatingWindow(key, data?)

There is no separate floating web window; forwards to ui.call. [limited]

ui.eval(code)

Runs JavaScript in a separate script context (not inside the UI page) with a 10 s limit. [limited]

ui.evalFloatingWindow(code)

Same as ui.eval. [limited]

pip — Floating window (PiP)

Uses system Picture-in-Picture as a floating window: log mode, keep-alive mode or custom text. Its position is controlled by iOS.

Modes: agent, hid

pip.isPipActive()

Whether the floating window is showing.

pip.switchToLogMode()

Shows script logs in the window.

pip.switchToKeepAliveMode()

Keep-alive mode.

pip.switchToCustomMode()

Custom text mode.

pip.closeWindow()

Closes the window.

pip.setContentSize(width, height)

Sets the content size (log/custom mode only).

pip.setPosition(x, y)

Not supported: iOS decides the PiP position. [unsupported]

pip.setLogFontSize(fontSize)

Log text size.

pip.setCustomText(text)

Custom-mode text.

pip.setCustomTextColor(color)

Custom text color.

pip.setCustomTextSize(fontSize)

Custom text size.

pip.setCustomBackgroundColor(color)

Custom background color.

thread — Script threads

Runs another script file in parallel in its own context. Exchange data through sharedState. JavaScript only (Python: threading; Lua: StartThread / StopThread).

Modes: agent, hid

thread.run(fileName, params?)

Starts a script thread.

var t = thread.run('worker_thread.js', {n: 3});

thread.stopAll()

Requests all running threads to stop.

tts — Text to speech

Speech synthesis with the system voices.

Modes: agent, hid

tts.speak(text, rate?, pitch?, volume?, language?)

Queues speech (non-blocking).

tts.speak('任务完成'); tts.waitEnd();

tts.waitEnd()

Blocks until queued speech finishes.

tts.stop()

Stops speaking.

tts.isSpeaking()

Whether speech is in progress.

tts.getAvailableVoices()

Lists system voices.

tts.setVoice(voiceIdentifier)

Selects a voice.

tts.free()

Stops and releases the synthesizer.

Connect ketec to your own WebSocket control server, report custom data and receive custom events.

Modes: agent, hid

cloud.connect(url, deviceNo?)

Connects for this run (does not change saved settings).

cloud.isConnected()

Connection state.

cloud.disconnect()

Disconnects.

cloud.report(event, data)

Sends {type:"scriptReport", event, data} to the server.

cloud.report('task.finished', {ok: true});

cloud.onEvent(callback)

Registers the single custom-event listener (delivered while the package script runs).

netCard — License cards

Online card-key verification for the currently loaded script package.

Modes: agent, hid

netCard.isAuthCardMode()

Whether card-key mode is on.

netCard.verify(cardNo)

Verifies online and stores the card for this package.

netCard.getCardInfo()

Returns verified card info.

netCard.setCardRemark(remark)

Sets the server-side remark of the card.

hotUpdate — Package hot update

Checks for and installs a newer version of the current script package from the configured distribution server. [unverified on device]

Modes: agent, hid

hotUpdate.checkUpdate()

Checks whether an update exists. [unverified] [limited]

hotUpdate.downloadAndInstall()

Downloads and installs; in a package run the script restarts at the next sleep() or when it ends. [unverified] [limited]

hotUpdate.getCurrentVersion()

Current package version.

ai — LLM helper

Stores LLM provider settings and sends prompts. [unverified] Not tested on device in this release; see each function for known limitations found in the source.

Modes: agent, hid

ai.setProvider(config)

Adds or updates a provider. [unverified]

ai.getProviders()

Lists providers.

ai.getDefaultProvider()

Returns the default provider id (a string, not an object). [limited]

ai.setDefaultProvider(id)

Stores the default provider id.

ai.removeProvider(id)

Returns true, but source review shows the provider is not actually removed in this build. [unverified] [limited]

ai.ask(prompt, options?)

Sends one prompt to an OpenAI-compatible chat endpoint. Source review: it reads an older endpoint setting that setProvider(config) does not write, so it may return {error} even after setProvider. [unverified] [limited]

ai.judge(question, options?)

Asks the model for true/false. Returns false without a default provider; since ask() returns an object, the result is false in practice. [unverified] [limited]

ai.extract(prompt, options?)

Asks the model to output JSON fields and parses it. Same limitation as judge. [unverified] [limited]

ai.chat(messages, options?)

Same as ask with a single prompt. [unverified] [limited]

ai.parseJson(text)

Parses JSON, also extracting the first {...} or [...] block from surrounding text.

ai.lastError()

Returns the stored last error (not updated by ask in this build). [unverified] [limited]

yolo — YOLO object detection

On-device YOLO detection with ncnn models (.param + .bin; v5/v8/v11/v26). You supply the model files.

Modes: agent, hid

yolo.load(paramPath, binPath, nc?, version?, useGpu?)

Loads a model.

yolo.detectAbs(modelId, img, x?, y?, ex?, ey?, targetSize?, threshold?, nmsThreshold?)

Runs detection.

var m = yolo.load('m.param','m.bin'); var r = yolo.detectAbs(m, 'screen');

yolo.free(modelId)

Releases a model.

yolo.freeAll()

Releases all models.

yolo.detect(modelId, img, targetSize?, threshold?, nmsThreshold?)

Whole-image detection.

yoloCls — YOLO classification

On-device YOLO classification with ncnn models.

Modes: agent, hid

yoloCls.load(paramPath, binPath, nc?, useGpu?)

Loads a classifier.

yoloCls.classify(modelId, img, targetSize?)

Classifies the whole image.

yoloCls.classifyRegion(modelId, img, x?, y?, ex?, ey?, targetSize?)

Classifies a region.

yoloCls.free(modelId)

Releases a model.

yoloCls.freeAll()

Releases all models.

cv — OpenCV

OpenCV 4.14 bindings for JavaScript and Lua. Images are Mat handles (strings like "$CV_MAT$_…"); functions take Mat handle(s) plus an options object using OpenCV parameter names and return new Mat handles or plain values; failures return undefined (reason in the log). Convert with cv.fromImageId / cv.toImageId and release Mats with cv.release. Python scripts use the bundled cv2 + numpy instead (image.captureMat()).

Modes: agent, hid

cv.BFMatcher(...)

Brute-force descriptor matching.

cv.CLAHE(...)

Contrast-limited adaptive histogram equalization.

cv.Canny(...)

Canny edge detection.

cv.FAST(...)

FAST corner detection.

cv.FlannBasedMatcher(...)

FLANN descriptor matching.

cv.GaussianBlur(...)

Gaussian blur.

cv.HoughCircles(...)

Detect circles (Hough transform).

cv.HoughLinesP(...)

Detect line segments (probabilistic Hough).

cv.HuMoments(...)

Hu invariant moments from moments.

cv.LUT(...)

Look-up table transform.

cv.Laplacian(...)

Laplacian filter.

cv.Mat(...)

Create a Mat filled with a scalar ({rows, cols, type, scalar}).

cv.ORB(...)

ORB keypoints and descriptors.

cv.SIFT(...)

SIFT keypoints and descriptors.

cv.Scharr(...)

Scharr derivative.

cv.Sobel(...)

Sobel derivative.

cv.absdiff(...)

Per-element absolute difference.

cv.adaptiveThreshold(...)

Adaptive threshold.

cv.add(...)

Per-element addition.

cv.addWeighted(...)

Weighted sum of two images.

cv.approxPolyDP(...)

Polygon approximation of a contour.

cv.arcLength(...)

Contour perimeter.

cv.arrowedLine(...)

Draw an arrowed line.

cv.at(...)

Read one pixel (row, col) as a channel array.

cv.bilateralFilter(...)

Bilateral filter.

cv.bitwise_and(...)

Bitwise AND.

cv.bitwise_not(...)

Bitwise NOT.

cv.bitwise_or(...)

Bitwise OR.

cv.bitwise_xor(...)

Bitwise XOR.

cv.blur(...)

Box blur.

cv.boundingRect(...)

Upright bounding rectangle.

cv.boxFilter(...)

Box filter.

cv.boxPoints(...)

Corner points of a rotated rectangle.

cv.calcBackProject(...)

Histogram back projection.

cv.calcHist(...)

Compute a histogram.

cv.capture(...)

Screenshot as a BGR Mat (optional x, y, ex, ey crop).

cv.circle(...)

Draw a circle.

cv.clone(...)

Copy a Mat.

cv.compare(...)

Per-element comparison.

cv.compareHist(...)

Compare two histograms.

cv.connectedComponents(...)

Label connected components.

cv.connectedComponentsWithStats(...)

Connected components with statistics.

cv.contourArea(...)

Contour area.

cv.convertScaleAbs(...)

Scale, take absolute value, convert to 8-bit.

cv.convexHull(...)

Convex hull of points.

cv.convexityDefects(...)

Convexity defects of a contour.

cv.copyMakeBorder(...)

Add a border around an image.

cv.copyTo(...)

Copy a Mat (optionally with a mask).

cv.cornerHarris(...)

Harris corner response.

cv.cornerSubPix(...)

Refine corners to sub-pixel accuracy.

cv.countNonZero(...)

Count non-zero pixels.

cv.crop(...)

Crop to {x, y, ex, ey}.

cv.cvtColor(...)

Color space conversion.

cv.detectBarcode(...)

Detect and decode barcodes → {decoded[], types[], points} or undefined.

cv.detectQRCode(...)

Detect and decode a QR code → {decoded, points} or undefined.

cv.dilate(...)

Morphological dilation.

cv.distanceTransform(...)

Distance transform.

cv.divide(...)

Per-element division.

cv.drawContours(...)

Draw contours.

cv.drawKeypoints(...)

Draw keypoints.

cv.drawMarker(...)

Draw a marker.

cv.drawMatches(...)

Draw keypoint matches.

cv.ellipse(...)

Draw an ellipse.

cv.empty(...)

Whether a Mat is empty or invalid.

cv.encodeQRCode(...)

Generate a QR code image (264×264 BGR).

cv.equalizeHist(...)

Histogram equalization.

cv.erode(...)

Morphological erosion.

cv.estimateAffine2D(...)

Estimate a 2D affine transform.

cv.estimateAffinePartial2D(...)

Estimate a similarity transform.

cv.extractChannel(...)

Extract one channel.

cv.fastNlMeansDenoising(...)

Non-local means denoising (gray).

cv.fastNlMeansDenoisingColored(...)

Non-local means denoising (color).

cv.fillConvexPoly(...)

Fill a convex polygon.

cv.fillPoly(...)

Fill polygons.

cv.filter2D(...)

Convolve with a custom kernel.

cv.findContours(...)

Find contours.

cv.findHomography(...)

Find a perspective homography.

cv.findNonZero(...)

Coordinates of non-zero pixels.

cv.fitEllipse(...)

Fit an ellipse to points.

cv.fitLine(...)

Fit a line to points.

cv.flannKnnMatch(...)

FLANN k-nearest-neighbour matching.

cv.flip(...)

Flip an image.

cv.floodFill(...)

Flood fill.

cv.fromImageId(...)

Convert an image-module imageId to a Mat.

cv.getAffineTransform(...)

Affine matrix from 3 point pairs.

cv.getPerspectiveTransform(...)

Perspective matrix from 4 point pairs.

cv.getRectSubPix(...)

Sub-pixel rectangle extraction.

cv.getRotationMatrix2D(...)

Rotation matrix.

cv.getSize(...)

{width, height, channels, rows, cols, type} of a Mat.

cv.getStructuringElement(...)

Create a morphology kernel.

cv.getTextSize(...)

Measure text size for putText.

cv.goodFeaturesToTrack(...)

Shi-Tomasi corner detection.

cv.hconcat(...)

Concatenate horizontally.

cv.imdecode(...)

Decode Base64 image data to a Mat.

cv.imencode(...)

Encode a Mat to Base64 (jpg/png ...).

cv.imread(...)

Read an image file / imageId / "screen" / URL to a BGR Mat.

cv.imwrite(...)

Write a Mat to an image file.

cv.inRange(...)

Mask of pixels inside a range.

cv.inpaint(...)

Inpaint a masked region.

cv.invertAffineTransform(...)

Invert an affine matrix.

cv.isContourConvex(...)

Whether a contour is convex.

cv.isRelease(...)

Whether a Mat handle has been released.

cv.knnMatch(...)

k-nearest-neighbour descriptor matching.

cv.line(...)

Draw a line.

cv.matchShapes(...)

Compare two shapes.

cv.matchTemplate(...)

Template matching score map.

cv.matchTemplateLoc(...)

Template matching best location → {x, y, minVal, maxVal}.

cv.max(...)

Per-element maximum.

cv.mean(...)

Mean of each channel.

cv.meanStdDev(...)

Mean and standard deviation.

cv.medianBlur(...)

Median blur.

cv.merge(...)

Merge channels.

cv.min(...)

Per-element minimum.

cv.minAreaRect(...)

Minimum-area rotated rectangle.

cv.minEnclosingCircle(...)

Minimum enclosing circle.

cv.minMaxLoc(...)

Min/max values and their locations.

cv.moments(...)

Image/contour moments.

cv.morphologyEx(...)

Advanced morphology (open, close, gradient ...).

cv.multiply(...)

Per-element multiplication.

cv.norm(...)

Matrix norm.

cv.normalize(...)

Normalize value range.

cv.ones(...)

Create a Mat of ones.

cv.perspectiveTransform(...)

Apply a perspective matrix to points.

cv.phaseCorrelate(...)

Translation between two images.

cv.pointPolygonTest(...)

Point position relative to a contour.

cv.polylines(...)

Draw polylines.

cv.putText(...)

Draw text.

cv.pyrDown(...)

Downsample (Gaussian pyramid).

cv.pyrUp(...)

Upsample (Gaussian pyramid).

cv.rectangle(...)

Draw a rectangle.

cv.release(...)

Release a Mat handle.

cv.releaseAll(...)

Release all Mat handles.

cv.resize(...)

Resize an image.

cv.rotate(...)

Rotate by 90/180/270 degrees.

cv.set(...)

Write one pixel ({row, col, value}).

cv.split(...)

Split channels.

cv.subtract(...)

Per-element subtraction.

cv.sum(...)

Sum of each channel.

cv.threshold(...)

Fixed threshold.

cv.toImageId(...)

Convert a Mat to an image-module imageId.

cv.vconcat(...)

Concatenate vertically.

cv.warpAffine(...)

Apply an affine transform.

cv.warpPerspective(...)

Apply a perspective transform.

cv.zeros(...)

Create a Mat of zeros.

console — console

Standard console object (JavaScript). log/info/debug write info-level lines, warn/error write warning/error lines; table/dir/trace/assert also log; group*, count*, time*, profile*, clear, record*, timeStamp, takeHeapSnapshot and screenshot are no-ops. Inside a running script package, console provides only log/info/warn/error/debug.

Modes: agent, hid

jbclear — Jailbreak: data cleanup

Requires a jailbroken environment; not available in the TestFlight build.

jbclear.keychain(identifier)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbclear.allKeychain()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbclear.cookies()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbclear.caches(options?)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbclear.photos()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbclear.appData(bundleId)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbclear.getIdfa()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbclear.resetIdfa()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbclear.setIdfa(value)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbclear.getIdfv(bundleId)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbclear.resetIdfv(bundleId)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbclear.setIdfv(bundleId, value)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice — Jailbreak: device settings

Requires a jailbroken environment; not available in the TestFlight build.

jbdevice.setAutoLockMinutes(minutes)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.restoreAutoLock()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.getAutoLockMinutes()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.serialNumber()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.wifiMac()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.wifiInfo()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.wifiOn()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.wifiOff()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.isWifiOn()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.bluetoothOn()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.bluetoothOff()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.isBluetoothOn()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.cellularOn()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.cellularOff()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.isCellularOn()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.airplaneOn()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.airplaneOff()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.isAirplaneOn()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.joinWifi(ssid, password?, timeoutMs?)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.forgetWifi(ssid)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.listWifi()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.scanWifi(timeoutMs?)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.setVolume(volume)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.getVolume()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.setBrightness(brightness)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdevice.getBrightness()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdraw — Jailbreak: screen overlay drawing

Requires a jailbroken environment; not available in the TestFlight build.

jbdraw.rect(x, y, width, height, options?)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdraw.text(x, y, text, options?)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdraw.clear(id)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdraw.clearAll()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdylib — Jailbreak: dynamic libraries

Requires a jailbroken environment; not available in the TestFlight build.

jbdylib.open(name, defs?)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbdylib.isLoaded(name)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbpower — Jailbreak: power / charging

Requires a jailbroken environment; not available in the TestFlight build.

jbpower.info()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbpower.stopCharging()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbpower.startCharging()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbpower.setSmartCharging(min, max)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbpower.clearSmartCharging()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbshell — Jailbreak: shell

Requires a jailbroken environment; not available in the TestFlight build.

jbshell.exec(command, timeoutMs?)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbsystem — Jailbreak: system control

Requires a jailbroken environment; not available in the TestFlight build.

jbsystem.respring()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbsystem.reboot()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbsystem.restartSelf()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbsystem.getUserTracking()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbsystem.setUserTracking(enabled)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbsystem.getPersonalizedAdvertising()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbsystem.setPersonalizedAdvertising(enabled)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbsystem.getLocationServices()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbsystem.setLocationServices(enabled)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbsystem.jbroot(path)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbsystem.rootfs(path)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbvpn — Jailbreak: VPN

Requires a jailbroken environment; not available in the TestFlight build.

jbvpn.create(config)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbvpn.list()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbvpn.current()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbvpn.select(nameOrId)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbvpn.remove(nameOrId)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbvpn.connect(nameOrId?)

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbvpn.disconnect()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]

jbvpn.status()

Requires a jailbroken environment; not available in the TestFlight build. [unsupported]