全屏找图
<pre><code class="language-js">function 全屏找图(path, callback) {
return new Promise((resolve, reject) => {
requestScreenCapture();
var imageData = "";
if (/(http|https):\/\/(.*)?/.test(path)) {
imageData = images.load(path);
} else {
console.log("读取本机图片");
imageData = images.read(path);
}
if (imageData) {
let data = images.findImage(captureScreen(), imageData, {
threshold: 0.8
});
if (data) {
resolve(data)
} else {
reject("未找到图片")
}
} else {
reject("图片读取失败")
}
});
}
全屏找图("/sdcard/xiami/wx.jpg").then(data => {
click(data.x, data.y)
}).catch(err => {
console.log(err);
})
</code></pre>