函数文档

驰云益玩赚 v3.0 · 主脚本 · 全部英文函数名 + 中文使用说明

点击 / 找图 工具集

textClick(key)§3.3 [194-392]
最常用的文本点击函数。严格 EndsWith 匹配 + 短按点击。
function textClick(key: string) → boolean
if (textClick("开始任务")) { sleep(1000); }
textConClick(key)§3.3 [194-392]
Contains 模糊匹配 + 短按。搜索结果列表用。
function textConClick(key: string) → boolean
textPress(key)§3.3 [194-392]
仅匹配存在,不点击。
function textPress(key: string) → boolean
textClickmove(key, dx, dy)§3.3 [194-392]
文本匹配 + 偏移点击。
function textClickmove(key: string, dx: number, dy: number) → boolean
textExists(key)§3.3 [194-392]
纯判断函数。返回 true/false。
function textExists(key: string) → boolean
idclick(key)§3.3 [194-392]
通过 Android 资源 ID 查找并点击。
function idclick(key: string) → boolean
idTextclick(key, key2)§3.3 [194-392]
id 匹配 + text 校验(双重定位)。
function idTextclick(key: string, key2: string) → boolean
idExists(key)§3.3 [194-392]
纯判断。返回 true/false。
function idExists(key: string) → boolean
picfind(x1, y1, x2, y2, name, mode)§3.3 [194-392] ★
★ 最关键的图片查找函数。支持多图(name 用 "a|b|c" 分隔)。mode=0 仅查找,mode=1 查找到后点击。
function picfind(x1, y1, x2, y2: number, name: string, mode: number) → string | null
x1, y1区域左上角坐标
x2, y2区域宽高(不是右下角!)
name图片名(无 .png 后缀),支持 "a|b|c"
mode0=仅查找, 1=查找并点击
if (picfind(225, 1925, 274, 140, "微信登录页", 0)) { ... }
Findpicmach(x1, y1, x2, y2, name, color, m)§3.3 [194-392]
图片 + 颜色 双校验。仅斗鱼使用。
function Findpicmach(..., name, color: "#RRGGBB", m) → boolean
Findpicmove(x1, y1, x2, y2, dx, dy, name, mode)§3.3 [194-392]
图片找到后偏移点击。
function Findpicmove(..., dx: number, dy: number, name, mode) → string
regioncolor(color, x, y, w, h, m)§3.3 [194-392]
区域找色。threshold=9。m=1 时点击第一个匹配点。
function regioncolor(color: "#RRGGBB", x, y, w, h: number, m: number) → boolean
loadImage(name)§3.2 [165-192]
https://kyjy.cc/images/ 下载并缓存图片。
function loadImage(name: string) → Image | null
var img = loadImage("开始按钮");
if (picfind(446, 2265, 179, 91, "开始按钮", 0)) { ... }

设备信息(§3.8 Device Info [Lines: 486-594])

getScreenWidth()
获取设备屏幕宽度(像素)。
function getScreenWidth() → number
var w = getScreenWidth(); // 1080
getScreenHeight()
获取设备屏幕高度(像素)。
function getScreenHeight() → number
getDeviceId()
获取设备唯一 ID(androidId)。
function getDeviceId() → string
getDeviceSerial()
获取设备序列号。
function getDeviceSerial() → string
getAndroidVersion()
获取 Android 版本号,如 "12"。
function getAndroidVersion() → string
getSdkInt()
获取 SDK 版本号(int)。
function getSdkInt() → number
getDeviceBrand()
获取设备品牌(如 "OPPO")。
function getDeviceBrand() → string
getDeviceModel()
获取设备型号(如 "EPCM30")。
function getDeviceModel() → string
getIMEI()
获取设备 IMEI(需要权限),失败返回 ""。
function getIMEI() → string
getMac()
获取设备 Mac 地址,失败返回 ""。
function getMac() → string
getBatteryLevel()
获取电池电量 0~100,失败返回 -1。
function getBatteryLevel() → number
isDeviceCharging()
判断是否正在充电。
function isDeviceCharging() → boolean
keepScreenOn(on)
保持屏幕常亮。
function keepScreenOn(on: boolean)
keepScreenOn(true); // 常亮
keepScreenOn(false); // 取消
wakeScreen()
唤醒屏幕。
function wakeScreen()

应用控制(§3.9 App Control [Lines: 596-697])

launchApp(pkg)
启动应用。
function launchApp(pkg: string)
launchApp("com.play.earn");
waitForApp(pkg, timeout)
等待指定应用进入前台。
function waitForApp(pkg: string, timeout: number = 5000) → boolean
getCurrentPackage()
获取当前前台应用包名。
function getCurrentPackage() → string
uninstallApp(pkg)
卸载应用(需要 Root)。
function uninstallApp(pkg: string)
getAppNameByPkg(pkg)
通过包名获取应用名称。
function getAppNameByPkg(pkg: string) → string
listInstalledApps()
列出所有已安装应用包名。
function listInstalledApps() → Array<string>
isAppInstalled(pkg)
检查应用是否已安装。
function isAppInstalled(pkg: string) → boolean
openActivity(opts)
打开指定 Activity。
function openActivity(opts: object)
openActivity({ action: "android.settings.ACCESSIBILITY_SETTINGS" });
pressHome()
按 Home 键回到桌面。
function pressHome()
pressBack()
返回键。
function pressBack()
pressRecents()
按最近任务键。
function pressRecents()
pressPower()
模拟电源键(弹出电源对话框)。
function pressPower()

文件与剪贴板(§3.10 Files [Lines: 699-782])

readClipboard()
读取剪贴板内容。
function readClipboard() → string
writeClipboard(text)
写入剪贴板。
function writeClipboard(text: string)
writeClipboard("Hello");
readFile(path)
读取文本文件。
function readFile(path: string) → string
writeFile(path, content)
写入文本文件(覆盖)。
function writeFile(path: string, content: string)
appendFile(path, content)
追加写入文本文件。
function appendFile(path: string, content: string)
fileExists(path)
判断文件是否存在。
function fileExists(path: string) → boolean
ensureDir(path)
创建目录(不存在则创建)。
function ensureDir(path: string)
deleteFile(path)
删除文件或目录。
function deleteFile(path: string)
listFiles(dir)
列出目录下所有文件。
function listFiles(dir: string) → Array<string>

控制台(§3.11 Console [Lines: 784-800])

consoleLog(msg) / consoleError(msg) / consoleWarn(msg) / consoleInfo(msg) / consoleDebug(msg)
AutoX 控制台多色输出。
function consoleLog(msg) // 蓝色
consoleError(msg) // 红色
consoleWarn(msg) // 橙色
consoleInfo(msg) // 绿色
consoleDebug(msg) // 灰色
consoleLog("正常信息");
consoleError("出错了");
consoleAssert(expr, msg)
断言。expr 为 false 时输出 msg。
function consoleAssert(expr, msg)

线程与并发(§3.12 Threads [Lines: 802-818])

startThread(fn)
启动一个新线程执行函数。
function startThread(fn: function) → object
startThread(function() { while(true) { log("tick"); sleep(1000); } });
execScriptFile(path)
启动子脚本引擎。
function execScriptFile(path: string) → object
stopAllEngines() / stopCurrentEngine()
停止所有 / 当前引擎。
function stopAllEngines() / stopCurrentEngine()
runOnUI(fn)
在 UI 线程上执行。
function runOnUI(fn: function)
runAsync(fn)
异步执行,返回 Promise。
function runAsync(fn: function) → Promise

手势与按压(§3.13 Gestures [Lines: 820-848])

swipeTo(x1, y1, x2, y2, duration)
在两点之间模拟滑动。
function swipeTo(x1, y1, x2, y2, duration: number = 500)
swipeTo(500, 1500, 500, 500, 400); // 向上滑动
playGesture(duration, points)
模拟手势。
function playGesture(duration: number, points: number[][])
playGesture(500, [[100,100],[200,200],[300,300]]);
swipeLoop(x1, y1, x2, y2, count, delay)
连续滑动。
function swipeLoop(x1, y1, x2, y2, count: number, delay: number)
swipeLoop(500, 1500, 500, 500, 5, 800);

截图与图像(§3.14 Screen & Image [Lines: 850-934])

requestCapturePermission()
请求截图权限。返回 true=已授权。
function requestCapturePermission() → boolean
captureScreenSafe()
截取屏幕(容错)。
function captureScreenSafe() → Image | null
clipImage(img, x, y, w, h)
截取指定区域。
function clipImage(img, x, y, w, h) → Image
findColorIn(img, color, opts)
在图像中查找颜色。
function findColorIn(img, color, opts) → Point | null
findColorIn(img, "#FF0000", { region: [0,0,500,500], threshold: 9 });
findImageIn(img, template, opts)
在图像中查找图片。
function findImageIn(img, template, opts) → Point | null
findMultiColorsSafe(img, firstColor, points, opts)
多点找色。
function findMultiColorsSafe(img, firstColor, points, opts) → boolean
recycleImage(img)
回收图像内存。
function recycleImage(img)
imageFromBase64(b64) / imageToBase64(img, format)
Base64 与 Image 互转。
function imageFromBase64(b64) → Image
imageToBase64(img, format = "png") → string

通知与 Toast(§3.15 Notifications [Lines: 936-949])

showToast(msg) / showToastLog(msg)
显示 Toast 短消息 / Toast + 控制台日志。
function showToast(msg)
showToastLog(msg)
showToastLog("开始运行");
sendNotification(builder)
发送系统通知。
function sendNotification(builder: object)

时间与随机(§3.16 Time [Lines: 951-971])

nowMs() / nowSeconds()
当前时间戳(毫秒 / 秒)。
function nowMs() → number
nowSeconds() → number
randomInt(min, max)
生成 [min, max] 之间的随机整数。
function randomInt(min: number, max: number) → number
var d = randomInt(1000, 3000); // 1~3秒
formatDateTime(d, fmt)
格式化日期时间。
function formatDateTime(d?: Date, fmt: string = "yyyy-MM-dd HH:mm:ss") → string
formatDateTime(); // "2026-09-24 14:30:00"

加密与编码(§3.17 Crypto [Lines: 973-1001])

md5(input)
MD5 哈希。
function md5(input: string) → string
hash(input, algo)
SHA1 / SHA256 哈希。algo 默认 "SHA-256"。
function hash(input: string, algo?: string) → string
encodeBase64(input) / decodeBase64(input)
Base64 编码 / 解码。
function encodeBase64(input) → string
decodeBase64(input) → string

Shell & Root(§3.18 [Lines: 1003-1028])

execShell(cmd)
执行 shell 命令(普通权限)。
function execShell(cmd: string) → object
var r = execShell("ls /sdcard");
log(r.stdout);
execRootShell(cmd)
Root 执行 shell 命令。
function execRootShell(cmd: string) → object
hasRootPermission()
判断是否有 Root 权限。
function hasRootPermission() → boolean

业务流程

toggleLaoYu(mode)§4.1 [1033-1112]
toggleLaoYu代理开关。
function toggleLaoYu(mode: "off" | 其他) → boolean
chiyunAuth(mode, Game)§4.2 [1113-1294]
驰云平台扫码授权。Game="" 表示登录益玩赚。
function chiyunAuth(mode: string, Game: string) → boolean
searchAgain(mode)§4.3 [1295-1345]
从主页搜索游戏任务入口。★ 添加新游戏必改。
function searchAgain(mode: string)
claimTasks()§4.4 [1346-1390]
执行"去添加 → 领取"流程。
function claimTasks()
withdraw()§4.5 [1391-1464]
支付宝提现 3元→1元。
function withdraw()
backToEarnApp(mode)§4.6 [1465-1503]
回到主页。"快赚"走快赚页。
function backToEarnApp(mode: string)

main 控制器

main(mode)§5 [1505-2051]
单一游戏的主循环入口。根据 S.stage 调用对应阶段子函数。
function main(mode: string) → boolean
main("传说大陆");
main("王者之战");
mainStage0Login(mode, S)§5.1 [1571-1596]
stage 0。检测登录状态、调用chiyunAuth、toggleLaoYu代理。
function mainStage0Login(mode: string, S: object) → string
mainStage1Search(mode, S)§5.2 [1597-1691] ★
★ 添加新游戏必改!横竖屏判断 + 搜索 + 安装 + 登录。
function mainStage1Search(mode, S) → string
★ 修改位置:函数末尾的 if (mode == "...") 链,已有兜底从 GAMES 读 searchText
mainStage2Game(mode, S)§5.3 [1692-1886]
stage 2。竖屏游戏专用:实名 + 开始战斗 + 法力值切换 + 狂欢庆典。
function mainStage2Game(mode, S) → string
★ 游戏专属逻辑:函数内的法力值分支 if (mode == "..."),已有 GAMES.maxFali 兜底
mainStage3Fishing(mode, S)§5.4 [1887-2051]
stage 3。横屏斗鱼专用。
function mainStage3Fishing(mode, S) → string

添加一个新游戏 · 完整步骤

5 步接入一个新游戏

  1. 准备截图:把游戏的微信登录页、开始按钮、签到页等关键画面截图,命名如 微信登录页.png,上传到 https://kyjy.cc/images/
  2. 启动脚本添加 checkbox:在启动脚本的「游戏选择」卡片中按现有格式复制一行
  3. 主脚本添加调度:在 §6.5 Schedule [Lines: 2155-2191] 按现有游戏复制三行(flagMap 加一行)
  4. 阶段 1 添加点击:已有 GAMES 兜底自动点击 searchText,无需手改
  5. 阶段 2 添加专属逻辑(可选):如有特殊战斗逻辑,已有 maxFali 兜底

最小改动代码示例

// === 启动脚本 · 卡片 1 中添加 checkbox ===
<horizontal w="0" layout_weight="1" gravity="center_vertical">
    <checkbox id="gameMyNewGame" marginRight="6" />
    <text text="我的新游戏" textColor="{{COLOR_TEXT_SECONDARY}}" textSize="14sp" />
</horizontal>

// === 启动脚本 · DEFAULT_GAME_XXX 常量区添加 ===
var DEFAULT_GAME_MY_NEW_GAME = false;

// === 启动脚本 · loadConfig / saveConfig 添加 ===
gameMyNewGame = !!readStorage("gameMyNewGame", DEFAULT_GAME_MY_NEW_GAME);
savedStorages.put("gameMyNewGame", gameMyNewGame);

// === 主脚本 §2 GAMES 数组加一行 ===
{ key: "我的新游戏", name: "我的新游戏", stage: 2, searchText: "我的新游戏",
  maxFali: 3, orient: "v", enable: false }

// === 主脚本 §6.1 Storage [Lines: 2056-2075] 添加全局变量 ===
var Game我的新游戏 = savedStorages.get("Game我的新游戏");

// === §6.5 Schedule [Lines: 2155-2191] flagMap 加一行 ===
var flagMap = {
    ...,
    "我的新游戏": Game我的新游戏 == true
};

// 然后调用 runAllGames(flagMap) 即可
🏠