Global Shortcut Events
Overview
Shortcut events encapsulated in the global module.
Read UI
readAllUIConfig Read UI
- Read all UI config
- @param tmplName UI template file name
- @return
{json}JSON data
function main() {
var result = readAllUIConfig("Douyin template");
logd(result);
logd(JSON.stringify(result));
}
main();
readAllUIConfig2 Read UI config (new UI)
- Read UI parameter config
- Configure in designer: Control Center → UI Parameters (New)
- Requires EC iOS USB 6.28.0++
- Note: Requires new UI config. Read order: per-device first, then global if empty.
- If params contain
__from_global__, the value comes from global config - @param tmplName Parameter group name
- @param forceGlobal Force global config; true = ignore per-device config
- @return
{json}JSON data
function main() {
var result = readAllUIConfig2("Douyin template", false);
logd(result);
logd(JSON.stringify(result));
}
main();
Click Functions
clickPoint Click by coordinates
- Click at coordinates
- @param x X coordinate
- @param y Y coordinate
- @return
{boolean}
function main() {
var result = clickPoint(100, 100);
if (result) {
logd("Click succeeded");
} else {
logd("Click failed");
}
}
main();
clickPointPressure Click coordinates with pressure
- Click coordinates with pressure
- Requires EC iOS 6.4.0+
- @param x X coordinate
- @param y Y coordinate
- @param pressure Pressure value in range 0–1
- @return
{boolean}
function main() {
var result = clickPointPressure(100, 100, 0.2);
if (result) {
logd("Click succeeded");
} else {
logd("Click failed");
}
}
main();
longClickPoint Long click by coordinates
- Long-click at coordinates
- @param x X coordinate
- @param y Y coordinate
- @return
{boolean}
function main() {
var result = longClickPoint(100, 100);
if (result) {
logd("Click succeeded");
} else {
logd("Click failed");
}
}
main();
doubleClickPoint Double-click by coordinates
- Double-click at coordinates
- @param x X coordinate
- @param y Y coordinate
- @return
{boolean}
function main() {
var result = doubleClickPoint(100, 100);
if (result) {
logd("Click succeeded");
} else {
logd("Click failed");
}
}
main();
press Long-press by coordinates
- Long-press event
- @param x X coordinate
- @param y Y coordinate
- @param delay Long-press duration in milliseconds
- @return
{bool}true on success, false on failure
function main() {
var result = press(100, 100, 5000);
if (result) {
logd("Long press succeeded");
} else {
logd("Long press failed");
}
}
main();
Multi-touch
multiTouch Multi-touch
- Multi-touch
- Touch params: action — 0 = down, 1 = up, 2 = move,3 = pause
- x: X coordinate
- y: Y coordinate
- pointer: finger index (1, 2, 3, … for nth finger)
- delay: delay in ms before this action runs
- @param touch1
First finger touch point array, e.g.:
[{"action":0,"x":1,"y":1,"pointer":1,"delay":20},{"action":2,"x":1,"y":1,"pointer":1,"delay":20}] - @param touch2 Second finger touch point array
- @param touch3 Third finger touch point array
- @param touch4 Fourth finger touch point array
- @param touch5 Fifth finger touch point array
- @param timeout Multi-touch total timeout in milliseconds
- @return
{boolean}
function main() {
// First style: array-based
var touch1 = [
{"action": 0, "x": 500, "y": 1200, "pointer": 1, "delay": 1},
{"action": 2, "x": 500, "y": 1100, "pointer": 1, "delay": 20},
{"action": 2, "x": 500, "y": 1000, "pointer": 1, "delay": 20},
{"action": 1, "x": 1, "y": 1, "pointer": 1, "delay": 2}
]
// Second style: chained calls
var touch1 = MultiPoint
.get()
.action(0).x(500).y(1200).pointer(1).delay(100)
.next()
.action(2).x(500).y(1100).pointer(1).delay(100)
.next()
.action(2).x(500).y(1000).pointer(1).delay(100)
.next()
.action(2).x(500).y(900).pointer(1).delay(100)
.next()
.action(1).x(500).y(800).pointer(1).delay(100);
var touch2 = MultiPoint
.get()
.action(0).x(300).y(1200).pointer(2).delay(100)
.next()
.action(2).x(300).y(1100).pointer(2).delay(100)
.next()
.action(2).x(300).y(1000).pointer(2).delay(100)
.next()
.action(2).x(300).y(900).pointer(2).delay(100)
.next()
.action(1).x(300).y(800).pointer(2).delay(100);
var x = multiTouch(touch1, touch2, null, null, null, 30000);
logd("xxs " + x);
}
main();
Swipe Functions
swipeToPoint Swipe between coordinate points
- Swipe from one coordinate to another
- @param startX Start X coordinate
- @param startY Start Y coordinate
- @param endX End X coordinate
- @param endY End Y coordinate
- @param duration Duration in milliseconds
- @return Boolean true Swipe succeeded, false Swipe failed
function main() {
var result = swipeToPoint(10, 10, 100, 100, 200);
if (result) {
logd("Swipe succeeded");
} else {
logd("Swipe failed");
}
}
main();
swipeToPointPressure Swipe between points with pressure
- Swipe from one coordinate to another
- Requires EC control center 6.4.0+
- @param startX Start X coordinate
- @param startY Start Y coordinate
- @param endX End X coordinate
- @param endY End Y coordinate
- @param duration Duration in milliseconds
- @param pressure pressure 0–1
- @return Boolean true Swipe succeeded, false Swipe failed
function main() {
var result = swipeToPointPressure(10, 10, 100, 100, 200, 0.2);
if (result) {
logd("Swipe succeeded");
} else {
logd("Swipe failed");
}
}
main();
Drag Functions
drag Drag coordinates
- Drag from one coordinate to another
- @param startX Start X coordinate
- @param startY Start Y coordinate
- @param endX End X coordinate
- @param endY End Y coordinate
- @param duration Duration in milliseconds
- @return Boolean true Drag succeeded, false Drag failed
function main() {
var result = drag(10, 10, 100, 100, 200);
if (result) {
logd("Drag succeeded");
} else {
logd("Drag failed");
}
}
main();
Input Data
inputText Input text
- Enter text
- @param content Content
- @param duration execution time in milliseconds
- @return
{bool}true on success, false on failure
function main() {
var result = inputText("My content", 100);
if (result) {
logd("Yes");
} else {
logd("No");
}
}
main();
typingText Input text
- Enter text; simulates typing
- EC IOS 6.1.0+
- @param content Content
- @return
{bool}true on success, false on failure
function main() {
var result = typingText("My content");
if (result) {
logd("Yes");
} else {
logd("No");
}
}
main();
ioHIDEvent Simulate keyboard
- Simulate HID events, e.g. keyboard and shortcuts; see key values at
- https://ieasyclick.com/iosdocs/advance/keyboard
- @param eventPageID HID type
- @param eventUsageID HID usage
- @param delay typically 0.2; may have delay
- @return
{boolean}
function main() {
let x = ioHIDEvent("0x07", "0x11", 0.2)
logd(x)
}
main();
Screen Orientation
setOrientation Set screen orientation
- Set orientation; landscape supports 90° clockwise only
- Requires EC iOS control center 3.0.0+
- @param orientation 1 = portrait, 2 = 90° clockwise landscape
- @return
{boolean}
function main() {
let x = setOrientation(1)
logd(x)
}
main();
getOrientation Get screen orientation
- Get screen orientation
- Requires EC iOS control center 3.0.0+
- @return int | 0 = portrait, 1 = landscape (90° clockwise))
function main() {
let x = getOrientation()
logd(x)
}
main();
adjustScreenOrientation Adjust screen orientation
- Adjust screen orientation and coordinate system
- Requires EC iOS control center 3.0.0+
- @param orientation 0 = auto; 1 = forced portrait; 2 = forced 90° clockwise landscape
- @return JSON string,keys: orientation, screenWidth, screenHeight
function main() {
logd(setOrientation(1))
sleep(1000)
logd(getOrientation())
logd("adjustScreenOrientation {}", adjustScreenOrientation(0))
}
main();
System Key Functions
home Go to home screen
- Go to home screen
- @return
{null|Boolean}
function main() {
var result = home();
if (result) {
logd("Success");
} else {
logd("Failed");
}
}
main();
reboot Reboot device
- Reboot device
- Requires EC iOS 3.5.0+
- @return
{null|Boolean}
function main() {
var result = reboot();
if (result) {
logd("Success");
} else {
logd("Failed");
}
}
main();
homeScreen Force go to home screen
- Force go to home screen
- Requires EC iOS control center 3.0.0+
- @return
{null|Boolean}
function main() {
var result = homeScreen();
if (result) {
logd("Success");
} else {
logd("Failed");
}
}
main();
isLocked Whether screen is locked
- Whether screen is locked
- Requires EC iOS control center 3.0.0+
- @return
{null|Boolean}
function main() {
var result = isLocked();
if (result) {
logd("Success");
} else {
logd("Failed");
}
}
main();
lockScreen Lock screen
- Lock screen
- Requires EC iOS control center 3.0.0+
- @return
{null|Boolean}
function main() {
var result = lockScreen();
if (result) {
logd("Success");
} else {
logd("Failed");
}
}
main();
unlockScreen Unlock screen
- Unlock screen; must not have password, etc.
- Requires EC iOS control center 3.0.0+
- @return
{null|Boolean}
function main() {
var result = unlockScreen();
if (result) {
logd("Success");
} else {
logd("Failed");
}
}
main();
openApp Open app by bundle ID
- Open app by bundle ID; unlike appLaunch, uses command channel
- @param bundleId App bundle ID
- @return
{boolean}true on success, false on failure
function main() {
var result = openApp("com.tencent.xin");
if (result) {
logd("Success");
} else {
logd("Failed");
}
}
main();
openUrl Open URL
- Open URL; call takeMeToFront first to bring this app to foreground
- @param url URL
- @return
{boolean}true on success, false on failure
function main() {
takeMeToFront()
sleep(1000)
var r = openUrl("http://baidu.com");
logd(r)
}
main();
stopApp Stop app by bundle ID
- Stop app by bundle ID; unlike appKillByBundleId, uses command channel
- @param bundleId App bundle ID
- @return
{boolean}true on success, false on failure
function main() {
var result = stopApp("com.tencent.xin");
if (result) {
logd("Success");
} else {
logd("Failed");
}
}
main();
appLaunchByPrefix Launch app by prefix
- Find and launch app by bundle ID prefix
- @param bundleIdPrefix App bundle ID prefix; comma-separated
- @return
{boolean}true on success
function main() {
var result = appLaunchByPrefix("com.tencent.xin,123");
if (result) {
logd("Success");
} else {
logd("Failed");
}
}
main();
appLaunch Launch app
- Launch app
- Automation not required
- @param bundleId App bundle ID
- @return
{int}process ID
function main() {
var result = appLaunch("com.tencent.xin");
if (result > 0) {
logd("Success");
} else {
logd("Failed");
}
}
main();
appLaunchEx Open an app
- Open an app
- Requires EC iOS USB 6.25.0+
- Automation required
- @param bundleId App bundle ID
- @param ignoreState 1 = ignore previous state and open directly; otherwise ""
- @return
{boolean}true on success
function main() {
var result = appLaunchEx("com.tencent.xin", "1");
if (result) {
logd("Success");
} else {
logd("Failed");
}
}
main();
appKillByBundleId Kill app by bundle ID
- Kill process by bundle ID
- Automation not required
- @param bundleId App bundle ID
- @return
{boolean}true on success, false on failure
function main() {
var result = appKillByBundleId("com.tencent.xin");
if (result) {
logd("Success");
} else {
logd("Failed");
}
}
main();
appKillByBundleIdEx Kill app by bundle ID
- Kill process by bundle ID
- Requires EC iOS USB 6.25.0+
- Automation required
- @param bundleId App bundle ID
- @param ignoreState 1 = ignore previous state and kill process; otherwise ""
- @return
{boolean}true on success, false on failure
function main() {
var result = appKillByBundleIdEx("com.tencent.xin", "1");
if (result) {
logd("Success");
} else {
logd("Failed");
}
}
main();
installApp Install app by path
- Install app by path (automation not required)
- @param bundleId App bundle ID
- @param path IPA path on same PC as bridge
- @return
{string}"ok" = success; other string = failure
function main() {
var result = installApp("com.test.xin", "c:/a.ipa");
logd("result " + result);
if (result == "ok") {
logd("Success");
} else {
logd("Failed");
}
}
main();
uninstallApp Uninstall app by bundle ID
- Uninstall app by bundle ID (automation not required)
- @param bundleId App bundle ID
- @return
{string}"ok" = success; other string = failure
function main() {
var result = uninstallApp("com.test.xin");
logd("result " + result);
if (result == "ok") {
logd("Success");
} else {
logd("Failed");
}
}
main();
other Functions
setAssistiveTouch AssistiveTouch toggle
- Toggle AssistiveTouch floating ball
- Requires EC IOS 6.0.0+
- @param open true = show, false = hide
- @return
{boolean}true on success, false on failure
function main() {
var result = setAssistiveTouch(true);
logd(result);
}
main();
resetUsbConn Reset USB connection
- Reset USB connection; try when automation is enabled
- @return
{boolean}true on success, false on failure
function main() {
var result = resetUsbConn();
logd(result);
}
main();
reconnectUsb Reconnect USB
- Flash-disconnect USB and reconnect (like unplugging cable)
- Requires EC 7.2.0+
- @return
{boolean}true on success, false on failure
function main() {
var result = reconnectUsb();
logd(result);
}
main();
setAgentSetting Set agent program config
- Set agent program config
- @param ext is a map,e.g.
{"screenStreamQuality":100} - screenStreamQuality: screen mirroring quality 1–100
- screenStreamFramerate: screen mirroring framerate 10–60
- @return
{bool}true on success, false on failure
function main() {
// Omit map keys for properties you do not want to set
var result = setAgentSetting({"screenStreamQuality": 60, "screenStreamFramerate": 20});
logd(result);
}
main();
setAgentTimeout Set agent request timeout
- @param envTimeout Automation startup timeout (ms); 10000–15000
- @param readTimeout other request timeout (ms); 2000–5000
- @return
{boolean}true on success
function main() {
setAgentTimeout(10000, 3000);
}
main();
activeAppInfo Current running app bundle ID
- @param Current running app bundleId
- @return
{string}current running app bundleId
function main() {
let d = activeAppInfo();
logd(d);
}
main();
erasePhone Factory reset
- Factory reset (wipe device)
- Requires EC iOS USB 8.10.0+
- Use with caution; wipes device data and reboots automatically
- @return
{boolean}true on success, false on failure
function main() {
let d = erasePhone();
logd(d);
}
main();
Gallery Operations
uploadInsertImage Insert image into gallery
- Insert image into gallery via agent IPA
- Requires EC IOS 6.5.0 +
- @param path image path
- @return
{boolean}true on success, false on failure
function main() {
let d = uploadInsertImage("D:/a.jpg");
logd(d);
}
main();
uploadInsertVideo Insert video into gallery
- Insert video into gallery via agent IPA
- Requires EC IOS 6.5.0 +
- @param path video path
- @return
{boolean}true on success, false on failure
function main() {
let d = uploadInsertVideo("D:/a.mp4");
logd(d);
}
main();
File Operations
tip
Due to iOS sandbox isolation,file operations are limited,to app-shared or system directories only,e.g. /Downloads, /DCIM
fsyncFileOpr File operations on iOS device
- File operations on iOS device
- Requires EC 7.2.0+
- @param action Actions: list= list files or folders,rm= delete file or folder,mkdir = create folder
- @param path file path
- @return
{JSON}code=0 = success; data = payload; when action=list, data is an array with file path, size, etc.
function main() {
// List all files under /
let d = fsyncFileOpr("list", "/");
logd(JSON.stringify(d));
// List all files under /Downloads
d = fsyncFileOpr("list", "/Downloads");
logd(JSON.stringify(d));
// Create folder
d = fsyncFileOpr("mkdir", "/Downloads/123");
logd(JSON.stringify(d));
// Delete file or folder
d = fsyncFileOpr("rm", "/Downloads/123.txt");
logd(JSON.stringify(d));
}
main();
fsyncFilePushPull Pull file
- Push/pull files to/from iOS device
- Requires EC 7.2.0+
- @param action Actions: push = push file from PC to remote device,pull = pull file from device to PC
- @param srcPath Source path; for push = PC path; for pull = iOS path
- @param destPath Destination path; for push = iOS path; for pull = PC path
- @return
{json}code=0 means success
function main() {
// Push C:/a.txt to iOS device at /Downloads/a.txt
let d = fsyncFilePushPull("push", "C:/a.txt", "/Downloads/a.txt");
logd(JSON.stringify(d));
// Pull file to local machine
d = fsyncFilePushPull("pull", "/Downloads/a.txt", "c:/bb.txt");
logd(JSON.stringify(d));
}
main();