警告:

本文较为基础,大佬绕行,不喜勿喷

下面正式开始步骤

一:安装Autojs

开源下载链接:https://github.com/Ericwyn/Auto.js/releases

在Github上,国内下载较慢

想快一点的同学请移步下面的蓝奏云下载链接:

https://zimuv.lanzous.com/iMw1Lj8g9he

当然如果有其他渠道的大佬可以在评论区贴出来

安装后按提示开启无障碍

二:代码

由于各种手机有差异,屏幕大小不一,以及各种乱七八糟的因素,下面贴两段代码,以便大多数同学都能操作成功

1,屏幕解锁代码:

出处:https://blog.csdn.net/nomil9/article/details/85392672?utm_source=app

    auto(); // 自动打开无障碍服务/*判断屏幕锁定,解锁屏幕(数字密码)*/if (!device.isScreenOn()) {//息屏状态将屏幕唤醒device.wakeUp();//唤醒设备sleep(1000); // 等待屏幕亮起//miui锁屏滑动不能唤出密码输入 通过下拉通知栏点击时间进入密码解锁swipe(500, 30, 500, 1000, 300);sleep(400);//点击时间click(100, 120);//解锁 密码0401desc(0).findOne().click();desc(4).findOne().click();desc(0).findOne().click();desc(1).findOne().click();//等待解锁完成,返回并退出back();exit();   }

2,能量球收取脚本代码

出处:https://blog.csdn.net/congwulong/article/details/90524420?utm_source=app

var morningTime = "07:18";//自己运动能量生成时间
var startTime = "07:00";
var endTime = "7:35";
var screen_width = 1080;  //设置屏幕的宽度,像素值
var screen_height = 2340; //设置屏幕的高度,像素值unlock();
sleep(2000);threads.start(function(){//在子线程中调用observeKey()从而使按键事件处理在子线程执行events.observeKey();events.on("key_down", function(keyCode, events){//音量键关闭脚本if(keyCode == keys.volume_down){toast("您选择退出脚本!")sleep(2000);exit();}});
});mainEntrence();//程序主入口
function mainEntrence(){//前置操作prepareThings();do{//打开支付宝openAlipay();//蚂蚁庄园if(!checkTime()){//enterAntFarm();}//进入蚂蚁森林主页,收集自己的能量enterMyMainPage();//进入排行榜if(enterRank()){//进入好友主页,收好友能量enterOthers();}//结束后返回主页面whenComplete();}while(checkTime());get_alipay_points();exit();
}//蚂蚁会员积分
function get_alipay_points(){clickByTextDesc("我的",0);sleep(2000);clickByTextDesc("支付宝会员",0);sleep(8000);clickByTextDesc("领积分",0);sleep(2000);var i=0;for(i=0; i<10;i++){clickByTextDesc("点击领取",0);sleep(100);}back();sleep(1000);back();sleep(1000);clickByTextDesc("首页",0);
}//解锁
function unlock(){if(!device.isScreenOn()){//点亮屏幕device.wakeUp();//由于MIUI的解锁有变速检测,因此要点开时间以进入密码界面sleep(1000);swipe(500, 0, 500, 1900, 2000);click(100,150); //输入屏幕解锁密码,其他密码请自行修改sleep(2000);click(540,1800);sleep(500);click(540,1800);sleep(500);click(240,1620);sleep(500);click(540,1620);sleep(500);    }
}//获取权限和设置参数
function prepareThings(){setScreenMetrics(screen_width, screen_height);//toastLog("test1");//请求截图if(!requestScreenCapture()){toastLog("请求截图失败,脚本退出");exit();}sleep(3000);//toastLog("test2");
}//获取截图
function getCaptureImg(){    //captureScreen("/storage/emulated/0/DCIM/Screenshots/1.png");//sleep(500);var img0 = captureScreen();sleep(100);if(img0==null || typeof(img0)=="undifined"){toastLog("截图失败,脚本退出");exit();}else{return img0;}
}//从支付宝主页进入蚂蚁森林我的主页
function enterMyMainPage(){//五次尝试蚂蚁森林入var i=0;swipe(screen_width*0.5,screen_height*0.5,screen_width*0.5,screen_height*0.25,500);sleep(500);swipe(screen_width*0.5,screen_height*0.25,screen_width*0.5,screen_height*0.5,500);while (!textEndsWith("蚂蚁森林").exists() && !descEndsWith("蚂蚁森林").exists() && i<=5){sleep(1000);i++;   }  if(i>=5){toastLog("没有找到蚂蚁森林入口,尝试中");clickByTextDesc("首页",0);sleep(2000);swipe(screen_width*0.5,screen_height*0.3,screen_width*0.5,screen_height*0.7,1000);sleep(2000);swipe(screen_width*0.5,screen_height*0.3,screen_width*0.5,screen_height*0.7,1000);sleep(2000);}clickByTextDesc("蚂蚁森林",0);//等待进入自己的主页,10次尝试sleep(3000);i=0;while (!textEndsWith("种树").exists() && !descEndsWith("种树").exists() && i<=10){sleep(1000);i++;}toastLog("第"+i+"次尝试进入自己主页");if(i>=10){toastLog("进入自己能量主页失败");return false;}//收自己能量//clickByTextDesc("克",0);for(var row=screen_height*0.256;row<screen_height*0.376;row+=80)for(var col=screen_width*0.185;col<screen_width*0.815;col+=80){click(col,row);}toastLog("自己能量收集完成");sleep(100);return true;
}//进入排行榜
function enterRank(){toastLog("进入排行榜");sleep(2000);swipe(screen_width*0.5,screen_height*0.8,screen_width*0.5,screen_height*0.1,500);sleep(500);swipe(screen_width*0.5,screen_height*0.8,screen_width*0.5,screen_height*0.1,500);toastLog("查看更多好友");sleep(500);clickByTextDesc("查看更多好友",0);//等待排行榜主页出现sleep(3000);return true;
}//从排行榜获取可收集好友的点击位置
function  getHasEnergyfriend(type) {var img = getCaptureImg();//getCaptureImg();//var img = images.read("/storage/emulated/0/DCIM/Screenshots/2.png");var p=null;if(type==1){// 区分倒计时和可收取能量的小手p = images.findMultiColors(img, "#ffffff",[[0, -35, "#1da06d"],[0, 23, "#1da06d"]], {region: [1043,200 , 1, screen_height-300]});}if(p!=null){toastLog("找到好友");return p;}else {//toastLog("此页没有找到可收能量的好友");return null;}
}//在排行榜页面,循环查找可收集好友
function enterOthers(){sleep(1000);var i=1;var ePoint=getHasEnergyfriend(1);//不断滑动,查找好友while(ePoint==null){//如果到了收取自己能量的时间,先收取自己能量if(myEnergyTime()){return false;}swipe(screen_width*0.5,screen_height*0.7,screen_width*0.5,screen_height*0.1,500);sleep(1000);ePoint=getHasEnergyfriend(1);i++;//如果连续15次都未检测到可收集好友,无论如何停止查找 if(i>15){toastLog("程序可能出错,连续"+i+"次未检测到可收集好友");return false;}}//找到好友//进入好友页面,10次尝试click(ePoint.x,ePoint.y+20);sleep(3000);i=0;while (!textEndsWith("你收取TA").exists() && !descEndsWith("你收取TA").exists() && i<=10){sleep(1000);i++;}toastLog("第"+i+"次尝试进入好友主页");if(i>=10){toastLog("进入好友能量主页失败");return false;}//收能量//clickByTextDesc("克",0);for(var row=screen_height*0.256;row<screen_height*0.376;row+=80)for(var col=screen_width*0.185;col<screen_width*0.815;col+=80){click(col,row);}//等待返回好友排行榜back();//返回排行榜成功,继续enterOthers();}function clickByTextDesc(energyType,paddingY){var clicked = false;if(descEndsWith(energyType).exists()){descEndsWith(energyType).find().forEach(function(pos){var posb=pos.bounds();if(posb.centerX()<0 || posb.centerY()-paddingY<0){return false;}//toastLog(pos.id());var str = pos.id();if(str != null){if(str.search("search") == -1){click(posb.centerX(),posb.centerY()-paddingY);//toastLog("get it 1");clicked = true;   }}else{click(posb.centerX(),posb.centerY()-paddingY);//toastLog("get it 2");clicked = true;}sleep(100);});}if(textEndsWith(energyType).exists() && clicked == false){textEndsWith(energyType).find().forEach(function(pos){var posb=pos.bounds();if(posb.centerX()<0 || posb.centerY()-paddingY<0){return false;}//toastLog(pos.id());var str = pos.id();if(str != null){if(str.search("search") == -1){click(posb.centerX(),posb.centerY()-paddingY); //toastLog("get it 3"); clicked = true;  }}else{click(posb.centerX(),posb.centerY()-paddingY);//toastLog("get it 4");clicked = true;}sleep(100);});}return clicked;
}//结束后返回主页面
function whenComplete() {toastLog("结束");back();sleep(1500);back();
}function checkTime(){var now =new Date();var hour=now.getHours();var minu=now.getMinutes();var time_a=startTime.split(":");var time_b=endTime.split(":");var timea = 60*Number(time_a[0])+Number(time_a[1]);var timeb = 60*Number(time_b[0])+Number(time_b[1]);var time  = 60*hour + minu;if(time>=timea && time<=timeb){//sleep(2000);return true;}else{return false;}
}function myEnergyTime(){var now =new Date();var hour=now.getHours();var minu=now.getMinutes();var mytime=morningTime.split(":");if(mytime[0]==hour && (mytime[1]==minu || mytime[1]==minu-1) ){return true;}else{return false;}
}function enterAntFarm(){var i=0;sleep(2000);while (!textEndsWith("蚂蚁庄园").exists() &&!descEndsWith("蚂蚁庄园").exists() && i<=5){sleep(1000);i++;   }if(i>=5){return false;}clickByTextDesc("蚂蚁庄园",0);sleep(7000);//captureScreen("/storage/emulated/0/DCIM/Screenshots/2_1.png");//exit();click(931,2150);sleep(2000);click(340,1420);sleep(1000);click(340,1900);sleep(1000);click(230,1600);sleep(1000);click(930,1900);sleep(1000);click(670,1600);sleep(1000);//captureScreen("/storage/emulated/0/DCIM/Screenshots/2_2.png");back();sleep(2000);return true;
}function openAlipay(){//launchApp("Alipay");launchApp("支付宝");toastLog("等待支付宝启动");//sleep(3000);var i=0;while (!textEndsWith("扫一扫").exists() && !descEndsWith("扫一扫").exists() && i<=5){sleep(2000);i++;}toastLog("第"+i+"次尝试进入支付宝主页");if(i>=5){toastLog("没有找到支付宝首页");sleep(1000);clickByTextDesc("首页",0);return false;}return true;
}

三,将上述代码

上述代码按照下面操作分别导入Autojs软件

命名自己随意

四:测试

测试屏幕解锁脚本:定时执行,然后锁屏,等待到时间解锁,一般都会成功,如果出现失败,请重复步骤二

测试自动收取能量脚本,点击执行按钮,等待模拟操作

Autojs实现蚂蚁森林自动收取能量球相关推荐

  1. 【Appium】Python+Appium实现支付宝蚂蚁森林自动收取能量的一种解决方案

    代码有更新,适配新版支付宝,参见最新文章: [Appium][更新]Python+Appium实现支付宝蚂蚁森林自动收取能量 一.环境准备 首先,你需要一个能够运行代码的环境,这里包括: Node.j ...

  2. 如何使用 AccessibilityService 实现蚂蚁森林自动收取能量,无需Root,无需连接电脑

    如何使用 AccessibilityService 实现蚂蚁森林自动收取能量,无需Root,无需连接电脑 AccessibilityService 设计初衷在于帮助残障用户使用android设备和应用 ...

  3. 【Appium】【更新】Python+Appium实现支付宝蚂蚁森林自动收取能量

    一.前期准备 环境准备和以前的脚本可以参见之前的文章[Appium]Python+Appium实现支付宝蚂蚁森林自动收取能量的一种解决方案 二.更新内容 新版的支付宝APP更新了遍历蚂蚁森林好友列表的 ...

  4. adb 查看屏幕大小_蚂蚁森林自动收取能量、偷取能量、浇水(使用adb、python)...

    涉及到的技术: 1.python 2.adb 具备的功能: 1.自动收取能量 2.自动偷取能量 3.自动给指定的朋友浇水 使用方法: 1.打开电脑,USB线一头接手机,一头接电脑. 2.电脑运行pyt ...

  5. 苹果 python蚂蚁森林自动收能量_GitHub - dxp432/adb_python_alipay_AntForest: 蚂蚁森林自动收取能量、偷取能量、浇水(使用adb、python)...

    蚂蚁森林自动收取能量.偷取能量.浇水 蚂蚁森林自动收取能量.偷取能量.浇水(使用adb.python)adb_python_alipay_AntForest 涉及到的技术: 1.python 2.ad ...

  6. 使用Auto.js实现蚂蚁森林自动收取能量

    在网上看了一些自动收能量的脚本 根据自己的手机型号 华为荣耀9 分辨率为1980*1080 写了一个脚本 使用AutoJs运行 定时每天早上7点开始收能量(再也不用担心我的能量被偷啦 哈哈~) Aut ...

  7. 苹果 python蚂蚁森林自动收能量_蚂蚁森林自动收取能量、偷取能量、浇水(使用adb、python)...

    涉及到的技术: 1.python 2.adb 具备的功能: 1.自动收取能量 2.自动偷取能量 3.自动给指定的朋友浇水 使用方法: 1.打开电脑,USB线一头接手机,一头接电脑. 2.电脑运行pyt ...

  8. 分享一 AutoJs 蚂蚁森林自动收取能量和偷取能量

    首先声明,代码不是本人所写,只是做了点改动.本文的目的一是分享给大家,二算是记个笔记方便以后看. 最近看到AutoJs可以收蚂蚁森林的能量,自己也想写一个,所以就搜了几个大神的代码,在此基础上,边看边 ...

  9. 蚂蚁森林自动收能量的最新脚本

    环境必须是安卓7.0以上版本.中文界面. 安装软件,执行Auto.js代码.完成.注意自启动,锁定后台,无障碍服务,悬浮窗等权限允许. 注意需要把脚本和图片放到执行文件夹的同一目录下. 首先所有资料链 ...

最新文章

  1. 我是如何自学 Python 的
  2. 矩形内接任意多边形抠图(可以羽化边缘)
  3. 哈夫曼树(最优二叉树)(c/c++)
  4. docker对数据卷进行还原操作
  5. VTK:隐式平面小部件用法实战
  6. tensorflow越跑越慢_tensorflow sess.run()越来越慢的原因分析及其解决方法
  7. 求一个任意实数c的算术平方根g_初中数学实数相关知识点:这些小技巧,解题有大用...
  8. 企业网管服务器架设资料(极品中的极品)
  9. Can‘t we be more objective?:Is huawei better than iphone?
  10. 简书python_python实现简书点赞
  11. 23. Perfer non-member non-friend functions to member functions
  12. 超赞!墙裂推荐一个 MySQL 自动化运维工具!
  13. MT4API跟单软件详细分享
  14. IDEA安装插件IDE Eval Reset
  15. java redis 实现pv uv_redis实战-记录PV与UV
  16. struts中的redirect=true与redirect=false
  17. js如何判断Object是否为空?
  18. 网络编程——基于TCP协议的通讯录【课程设计】
  19. Android安全检测 - Janus签名漏洞
  20. QGIS插件grass使用出现“This algorithm cannot be run:”问题

热门文章

  1. SaaS智慧校园源码,电子班牌管理系统 人脸考勤、综合评价系统、请假管理、校务管理
  2. 交通信号灯控制系统设计
  3. 涂鸦智能选型 TiKV 的心路历程
  4. 基于共建共享提升高铁网络覆盖和感知的研究
  5. Bootstrap 反色导航条
  6. Swift:字符串格式化
  7. haproxy报错:Failed to start SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited ..
  8. C#调用摄像头的几种方式
  9. 【码蚁君】AR实战-圣诞礼物EasyAR+Unity
  10. 选对社群引流方式,业绩翻倍