星空软件

 找回密码
 立即注册

【Auto.js pro】 识图/找图教程,附教程和代码例子

和你相伴1 | 2022-4-11 12:40:46 | 显示全部楼层 |阅读模式
Auto Js
名称(name): 识图/找图
大小: 0 KB
开发者: 其他
是否开源: 开源版
功能介绍: 【Auto.js pro】 识图/找图教程
通过AUTo js可以免ROOT找图,识图并点击,其实实现方法很简单,就是调用系统的截图权限和无障碍权限就行了,我们下面会把具体的步骤一步步給大家讲解出来,方便大家学习哈
开发思路:
  • 截屏(含有公告界面)
  • 读取 “截屏图片”  ➤   剪切  ➤  保存  ➤ 得到 “✖”
  • 找图

我们需要注意的是:这3步要分开去执行~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

第一步:我们先把屏幕截屏一张
(截屏图片的保存路径:sdcard/Pictures/Screenshots/截屏的图片.jpg)
文件管理 ➤ 内部存储(sdcard) ➤ Pictures ➤ Screenshots ➤ 截屏的图片.jpg
如果不知道截图的文件保存在哪里,你可以进入图库,然后长按图片,然后查看该图片的属性找到具体路径。
截图202204111233297384.png
截图202204111233094107.png
截图202204111233412231.png
截图202204111233515596.png

用AUTO JS代码截图也非常简单奥
步骤:
requestScreenCapture(); 申请系统的截图权限
sleep(3000); 延时3秒
captureScreen("/sdcard/Pictures/Screenshots/公告" + ".jpg"); 截屏权限申请成功后就开始截图,然后把截屏后的图片保存到/sdcard/Pictures/Screenshots/目录
sleep(3000); 延时3秒
截图202204111236159113.png
第二步:读取 “截屏图片”  ➤   剪切  ➤  保存  ➤ 得到 “✖”

var src = images.read("/sdcard/Pictures/Screenshots/公告.jpg"); 读取图片

//images.clip(img, x, y, w, h)          images.clip(图片路径,  x,  y,  宽,  高)  剪切图片
var clip = images.clip(src, 2720, 60, 100, 110);

images.save(clip, "/sdcard/Pictures/Screenshots/公告_关闭.jpg"); 保存图片

截图202204111237211610.png
截图202204111239182175.png
[点击 "X",查看 坐标(X,Y) 的位置]
通过如上代码就剪辑出了这样的一个代码
//在 大图片 中查找 小图片 的位置(模块匹配),找到时返回位置坐标(Point),找不到时返回null。
var p = findImage(captureScreen(), img_small);
if (p) {
    toastLog("公告_关闭 - 找到了,坐标:" + p.x + "----" + p.y);
    click(p.x, p.y);//点击坐标
} else {
    toastLog("公告 - 未找到");
}
好了~ 找图完成
注意:找图后点击的位置 是 “公告_关闭.jpg” 的左上角
如果截出来的图片是这样的,直接  click(p.x, p.y);  是点击不到 “X” 的

截图202204111240424651.png




上一篇:一键获取路由器wan口pppoe账密的工具【最新通用版】
下一篇:按键精灵传奇自动打怪脚本,自动找怪打怪,跑图打怪传奇
回复

使用道具 举报

Olpzep | 2023-3-4 10:30:32 | 显示全部楼层

Trade with Confidence and Earn Consistent Profits with Binary Options

Hi!
Get started in the world of binary options trading with confidence! Our user-friendly platform offers a wide range of assets, fast trades and secure transactions. With returns of up to 800% and a minimum deposit of just $200, there's never been a better time to invest. #binaryoptions #trading #profits

WARNING! If you are trying to access the site from the following countries, you need to enable VPN which does not apply to the following countries!
Australia, Canada, USA, Japan, UK, EU (all countries), Israel, Russia, Iran, Iraq, Korea, Central African Republic, Congo, Cote d'Ivoire, Eritrea, Ethiopia, Lebanon, Liberia, Libya, Mali, Mauritius, Myanmar, New Zealand, Saint Vincent and the Grenadines, Somalia, Sudan, Syria, Vanuatu, Yemen, Zimbabwe.
https://cutt.us/5H7nx
Sign up and start earning from the first minute!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

全站声明【必看】|小黑屋|新库软件 |网站地图

GMT+8, 2024-4-20 13:32 , Processed in 0.067051 second(s), 28 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.