autojs教程:完善找图函数,图片内随机点击 | 您所在的位置:网站首页 › 70乘以100是多大尺寸 › autojs教程:完善找图函数,图片内随机点击 |
两个找图封装的 函数 autojs找图两种方法。 为什么又分享,因为很多人问我,找图找到了,但是点击为什么没反应?? !!! 找到图片了,但是点击的点是否在可点击有反应的区域内呢? 现在下面代码完美解决找到图片,点击无反应问题。 切下面代码是随机点击图片区域,避免被检测非人工。 ps:找图之前,最主要的必需的请求截图代码: //请求截图,用找图方法,第一个就要先写的请求截图代码,不然找图没法用 if (!requestScreenCapture()) { toast("请求截图失败"); exit(); }找图方法一: let 大图 = captureScreen() //大图就需截取手机屏幕。。意思就是截屏 let 小图 = images.read("/storage/emulated/0/Pictures/Screenshots/枪娘007/每日空投.png"); //括号里是图片地址。。 let p = findImage(大图, 小图); if (p) { log("找到啦:" + "每日空投"); let xx = random(p.x, p.x + 小图.getWidth()) let yy = random(p.y, p.y + 小图.getWidth()) click(xx, yy) log("一点击"); sleep(1000) } else { log("没找到" + "每日空投"); }找图方法二: let 大图 = captureScreen() let 小图 = images.read("/storage/emulated/0/Pictures/Screenshots/枪娘007/每日空投.png"); //括号里是图片地址。。 let result = images.matchTemplate(大图, 小图, { max: 5 }); if (result != null) { for (let i = 0; i < result.matches.length; i++) { let pp = result.matches[i].point // log(pp) let xx = random(pp.x, pp.x + 小图.getWidth()) let yy = random(pp.y, pp.y + 小图.getWidth()) console.log("找到" + "每日空投") click(xx, yy) console.log("点击" + "每日空投") sleep(2000) // break; } } else { console.log("===未找到" + "每日空投") } |
CopyRight 2018-2019 实验室设备网 版权所有 |