function requestScreenshot() {
let result = false;
let thread = threads.start(function () {
if (device.brand == 'vivo') {
text('取消').id('com.android.systemui:id/vbutton_title').waitFor();
sleep(1000)
let s = text('取消').findOnce()
console.log(s.bounds().centerX(), s.bounds().centerY() - 180);
click(s.bounds().centerX(), s.bounds().centerY() - 180)
} else {
packageName('com.android.systemui').text('立即开始').waitFor();
text('立即开始').click();
}
});
if (!requestScreenCapture()) {
toast("请求截图失败");
} else {
result = true;
thread.interrupt();
}
return result;
};
function clickCharEx_paddle(content, isDimFind, index, isClick, offsetX, offsetY, milliSecond) {
if (!milliSecond) { milliSecond = 1000 };
if (!index) { index = 0 };
if (!offsetX) { offsetX = 0 };
if (!offsetY) { offsetY = 0 };
let result = false;
requestScreenshot()
let img = captureScreen();
if (img) {
let res = paddle.ocr(img);
if (res && res.length > 0) {
for (let i = 0; i < res.length; i++) {
let ocrResult = res[i];
log(ocrResult);
if (isDimFind && ocrResult.words.indexOf(content) != -1) {
result = true;
} else if (content === ocrResult.words) {
result = true;
} else {
}
if (result) {
if (isClick) {
click(ocrResult.bounds.left + parseInt((ocrResult.bounds.right - ocrResult.bounds.left) / 2) + offsetX, ocrResult.bounds.top + parseInt((ocrResult.bounds.bottom - ocrResult.bounds.top) / 2) + offsetY);
}
break;
}
}
}
img.recycle();
} else {
log("截图失败");
}
if (result) {
sleep(milliSecond);
};
return result;
};