var th = threads.start(function() {
//在子线程中调用observeKey()从而使按键事件处理在子线程执行
events.observeKey();
events.on("key_down", function(keyCode, events) {
//音量键关闭脚本
if (keyCode == keys.volume_down) {
toast("您选择退出脚本!")
sleep(1000);
th.interrupt();
exit();
}
});
});
if (!requestScreenCapture()) {
toastLog("请求截图失败,脚本退出");
exit();
}
sleep(1000);
//原图
img0 = images.read("/storage/emulated/0/DCIM/Screenshots/202101280.png");
//从原图截取的小图
temp0 = images.read("/storage/emulated/0/DCIM/Screenshots/叉.png");
result = images.matchTemplate(img0, temp0, {
max: 1,
region: [485, 1697, 120, 120],
threshold: 0.8
})
sleep(1000);
try {
alert("matches[i] " + result.matches[4].point.x + result.matches[0]['similarity']);
toastLog("points[i] " + result.points[0]);
toastLog("first() " + result.first().point.x);
toastLog("last() " + result.last());
toastLog(objLen);
}
catch (e) {
alert("未匹配" + e.name);
}
toastLog("完成");
img0.recycle();
temp0.recycle();
exit();


//在子线程中调用observeKey()从而使按键事件处理在子线程执行
events.observeKey();
events.on("key_down", function(keyCode, events) {
//音量键关闭脚本
if (keyCode == keys.volume_down) {
toast("您选择退出脚本!")
sleep(1000);
th.interrupt();
exit();
}
});
});
if (!requestScreenCapture()) {
toastLog("请求截图失败,脚本退出");
exit();
}
sleep(1000);
//原图
img0 = images.read("/storage/emulated/0/DCIM/Screenshots/202101280.png");
//从原图截取的小图
temp0 = images.read("/storage/emulated/0/DCIM/Screenshots/叉.png");
result = images.matchTemplate(img0, temp0, {
max: 1,
region: [485, 1697, 120, 120],
threshold: 0.8
})
sleep(1000);
try {
alert("matches[i] " + result.matches[4].point.x + result.matches[0]['similarity']);
toastLog("points[i] " + result.points[0]);
toastLog("first() " + result.first().point.x);
toastLog("last() " + result.last());
toastLog(objLen);
}
catch (e) {
alert("未匹配" + e.name);
}
toastLog("完成");
img0.recycle();
temp0.recycle();
exit();


