牙叔教程 简单易学
使用场景
你有多个脚本, 想让他们一个一个按顺序执行
效果展示

autojs版本

知识点
- 脚本是否已经销毁
- 获取指定脚本引擎
- 停止指定脚本
- 删除数组第一个元素
代码
// 在此处给脚本排队即可
let filePathList = ["1.js", "2.js", "3.js"];
// let filePathList = ["2.js", "1.js", "3.js"];
filePathList = filePathList.map(function (filePath) {
return files.path(filePath);
});
events.on("exit", function () {
log("exit");
});
setInterval(function () {}, 1000);
let limitTime = 3000;
while (1) {
if (filePathList.length > 0) {
let e = engines.execScriptFile(filePathList[0]);
while (!e.getEngine()); //等待脚本运行
let currentScriptEngine = e.getEngine();
let lastTime = new Date().getTime();
while (1) {
let currentTime = new Date().getTime();
if (currentTime - lastTime > limitTime) {
log("脚本运行超时, 开始 执行销毁命令");
currentScriptEngine.forceStop();
log("脚本运行超时, 结束 执行销毁命令");
break;
}
if (currentScriptEngine.isDestroyed()) {
break;
} else {
sleep(100);
}
}
} else {
engines.myEngine().forceStop();
}
filePathList.shift();
}
声明
部分内容来自网络
bilibili
微信公众号 牙叔教程

QQ群
747748653

1万+

被折叠的 条评论
为什么被折叠?



