//启用按键监听,按下音量下键脚本结束
function overjs(){
threads.start(function(){//在子进程中运行监听事件
events.observeKey();
events.on("key", function(code, event){
    var keyCodeStr = event.keyCodeToString(code);
    console.log(code);
    console.log(keyCodeStr);
    if(keyCodeStr=="KEYCODE_VOLUME_DOWN"){
        toast("程序已结束。");
        exit();
    }
});
});
}

设置监听音量减键,如果按下音量减(-)这个键,脚本自动结束

 

自动实现截屏功能,不需要再次手动点击“立即开始”

// 截图权限申请
threads.start(function () {
    var beginBtn;
    if (beginBtn = classNameContains("Button").textContains("立即开始").findOne(2000)) {
        beginBtn.click();
    }
});
sleep(1000);
if (!requestScreenCapture(false)) {
    toastLog("请求截图失败");
    exit();
}
threads.shutDownAll();//停止所有通过threads.start()启动的子线程

 

相关文章:

  • 2022-02-10
  • 2022-12-23
  • 2022-02-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-22
猜你喜欢
  • 2022-01-07
  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
  • 2021-11-04
  • 2021-09-11
  • 2022-12-23
相关资源
相似解决方案