const permissionsScreenshot = screenshotRequest()
if (!requestScreenCapture()) {
toast("请求截图失败");
exit();
} else {
permissionsScreenshot && permissionsScreenshot.interrupt()
sleep(2000)
img = captureScreen();
base64 = images.toBase64(img)
log(
http
.request("http://xxx:xxx:xxx:xxx:xxx/ocr_data_2", {
method: "post",
body: base64,
headers: {
"Content-Type": "application/json;charset=UTF-8",
},
})
.body.json())
}
/* 截图权限 */
function screenshotRequest() {
console.log("开启截图权限")
return threads.start(function () {
while (true)
if (text("立即开始").exists()) {
sleep(500)
Bounds(text("立即开始").findOne())
} else if (text("允许").exists()) {
sleep(500)
Bounds(text("允许").findOne())
}
})
}
/**
* 点击
* @param {控件} obj
*/
function Bounds(obj) {
try {
obs = obj.bounds();
click((Math.abs(obs.left) + Math.abs(obs.right)) / 2, (Math.abs(obs.top) + Math.abs(obs.bottom)) / 2);
} catch (e) {
Bounds(obj);
}
}
飞浆OCR_autojs
最新推荐文章于 2023-08-18 08:45:14 发布