AutoJs6 中文文档 下载 App

插件中心与其他实用工具 — v6.7 新增功能速览

插件中心

v6.7 新增的插件中心让 AutoJs6 功能可以按需扩展。

入口

已发布插件

插件功能说明
Paddle OCR (PP-OCRv5)高精度中文 OCRPaddle Lite 引擎,比 ML Kit 更准

安装与更新

插件中心 → 浏览可用插件
  → 点击"安装"
  → 等待下载完成
  → 安装后在脚本中直接可用

更新:
  插件中心 → 已安装 → 检查更新 → 更新

卸载:
  插件中心 → 已安装 → 卸载

使用已安装插件

// 安装 Paddle OCR 后,直接切换引擎
ocr.mode = "paddle";  // 使用 Paddle Lite 引擎

// 其他用法和 ML Kit 引擎完全一样
let result = ocr.detect(screen);
console.log(result.text);

notice 通知模块

发送系统通知

// 简单通知
notice.notify("脚本运行中", "正在执行签到...");

// 完整通知
notice.notify({
    title: "签到完成",
    content: "已完成 3 个应用的签到",
    id: 123,           // 通知 ID(相同 ID 会覆盖旧通知)
    sound: true,       // 声音
    vibrate: true,     // 震动
    lights: true,      // 呼吸灯
    bigText: "完整内容..."  // 大文本样式
});

// 取消通知
notice.cancel(123);
notice.cancelAll();

检查通知权限

if (!notice.canNotify()) {
    toast("请授予通知权限");
    notice.requestPermission();
}

qrcode 二维码模块

// 生成二维码
let code = qrcode.encode("https://docs.autojs6.com");
// code 是 Image 对象
images.save(code, "/sdcard/autojs6_qr.png");

// 解析二维码
let result = qrcode.decode("/sdcard/auto_qr.png");
if (result) {
    console.log("二维码内容: " + result);
}

// 从屏幕截图解析
let screen = images.captureScreen();
let decoded = qrcode.decodeImage(screen);
screen.recycle();

if (decoded) {
    console.log("屏幕上有二维码: " + decoded);
}

cvt 单位转换(v6.7 新增)

// 字节单位转换
cvt.bytes(1024);           // 1 KB
cvt.bytes(1048576);        // 1 MB
cvt.bytes(1073741824);     // 1 GB

// 指定目标单位
cvt.bytes(1048576, "KB");  // 返回 1024

// 其他单位转换
// 温度、长度、重量等(具体见官方文档)

fmt 格式化(v6.7 新增)

// 字节格式化
fmt.bytes(1048576);        // "1.00 MB"
fmt.bytes(1024);           // "1.00 KB"
fmt.bytes(1073741824);     // "1.00 GB"

// 数字格式化
fmt.number(1234567);       // "1,234,567"
fmt.number(3.14159, 2);    // "3.14"

// 百分比
fmt.percent(0.8567, 2);    // "85.67%"

zip 压缩解压(v6.7 新增)

// 解压 zip 文件
zip.unzip("/sdcard/archive.zip", "/sdcard/extracted/");

// 压缩目录
zip.zip("/sdcard/myFolder", "/sdcard/archive.zip");

// 压缩文件列表
zip.zipFiles(
    ["/sdcard/file1.js", "/sdcard/file2.json"],
    "/sdcard/scripts.zip"
);

// 解压密码保护的 zip
zip.unzip("/sdcard/secret.zip", "/sdcard/out/", "password123");

mediainfo 媒体信息(v6.7 新增)

// 获取媒体文件信息
let info = mediainfo.get("/sdcard/video.mp4");

console.log("时长: " + info.duration + " ms");
console.log("宽高: " + info.width + "x" + info.height);
console.log("文件大小: " + info.fileSize + " bytes");
console.log("比特率: " + info.bitrate);
console.log("编码格式: " + info.codec);
console.log("帧率: " + info.frameRate);

base64 编解码

// 编码
let encoded = base64.encode("AutoJs6");
console.log(encoded);  // "QXV0b0pzNg=="

// 解码
let decoded = base64.decode("QXV0b0pzNg==");
console.log(decoded);  // "AutoJs6"

crypto 加密解密

// MD5
let md5 = crypto.md5("AutoJs6");
console.log("MD5: " + md5);

// SHA-1
let sha1 = crypto.sha1("AutoJs6");

// SHA-256
let sha256 = crypto.sha256("AutoJs6");

// AES 加密
let encrypted = crypto.encrypt("AutoJs6", "password123");

// AES 解密
let decrypted = crypto.decrypt(encrypted, "password123");
console.log(decrypted);  // "AutoJs6"

其他内置模块速查

模块功能典型方法
colors颜色处理colors.parseColor(), colors.equals(), colors.similar()
events事件监听events.on(), events.once(), events.off()
dialogs对话框dialogs.alert(), dialogs.confirm(), dialogs.prompt()
floaty悬浮窗floaty.rawWindow(), floaty.window(), floaty.closeAll()
sensors传感器sensors.lightSensor(), sensors.proximity()
media媒体控制media.playMusic(), media.pauseMusic(), media.volumeUp()
barcode条码扫描barcode.scan()
opencc繁简转换opencc.toSimplified(), opencc.toTraditional()
i18n国际化i18n.tr()
s13n标准化s13n.bytes()
sqlite数据库sqlite.open(), db.execSQL(), db.query()

storage 本地存储

// 简单 KV 存储(推荐)
storage.put("key", "value");
let val = storage.get("key", "default");  // 第二个参数是默认值

// 删除
storage.remove("key");
storage.clear();

// 复杂对象也可以
storage.put("config", {
    enabled: true,
    timeout: 5000,
    items: [1, 2, 3]
});
let config = storage.get("config");
console.log(config.enabled); // true

注意事项