关于autojs的定时停止实例源码

/*
*@更多基础不会的加autojs交流群553908361喽;版权属于群友
一键加群:点击加群
//黑马学府脚本资源网jiaoben.info更多源码发布
*
在这里插入图片描述
在这里插入图片描述
由群里小萌新提出,群友热心解答得出

run();
//实时显示脚本运行时长,并对返回的时长与设定的时长进行判断
function run() { //声明运行函数
    threads.start(function() {
        startTime = new Date().getTime();
    
        while (true) {
            runTime();
            sleep(1000);
        }
    });
}

function runTime() {
    var endTime = new Date().getTime();
    var spendTime = Math.floor((endTime - startTime) / 1000);
    log('已等待%d秒', spendTime);
    let t = 3;
    if (spendTime >= t) {
        console.info("定时已结束");
        exit();
    }
}

猜你喜欢

转载自blog.csdn.net/qq_30931547/article/details/112749299