哪位大神帮忙看看这是哪里错了 执行不了啊
autojs吧
全部回复
仅看楼主
level 1
哈哈笑4214 楼主
// 星途星纪元定时执行脚本(优化版)setScreenMetrics(2800, 1264); // 荣耀Magic6分辨率
// 定义目标执行时间(14:18)const TARGET_HOUR = 14;const TARGET_MINUTE = 18;// 定义星途星纪元实际包名(需替换为真实包名)const APP_PACKAGE = "com.starway.xyj";
// 检查是否今天已执行if (!storage.get("executed_today", false)) { const now = new Date(); // 生成今日目标时间(14:18) const targetTime = new Date( now.getFullYear(), now.getMonth(), now.getDate(), TARGET_HOUR, TARGET_MINUTE ); // 判断当前时间是否超过目标时间 if (now.getTime() >= targetTime.getTime()) { try { // 执行任务 launchApp("星途星纪元"); sleep(5000); // 等待APP加载 click(1052, 2479); sleep(1000); click(1023, 576); click(697, 1456); sleep(2000); // 等待操作完成 // 关闭APP(使用实际包名) if (shell(`am force-stop ${APP_PACKAGE}`, true).exitValue !== 0) { toast("APP关闭失败,尝试其他方式"); exitApp("星途星纪元"); } // 标记今天已执行 storage.put("executed_today", true); toast("任务执行完成"); } catch (e) { toast(`执行出错:${e.message}`); } }}
// 优化午夜重置逻辑(仅创建一次定时任务)if (!global.resetTaskSet) { // 每天0点重置执行标记 schedule("0 0 0 * * ?", function() { storage.put("executed_today", false); toast("今日执行标记已重置"); }); global.resetTaskSet = true;}
2025年07月06日 06点07分 1
1