GitHub地址:https://github.com/hyb1996/Auto.js

文档地址:https://hyb1996.github.io/AutoJs-Docs/#/?id=%E7%BB%BC%E8%BF%B0

Android软件下载:https://www.coolapk.com/apk/129872

  今天看今日头条无意间看到个蚂蚁森林自动收能量的脚本,于是打开看看安全性。

下面是代码:

 auto();
//auto.waitFor(); requestScreenCapture();
//解锁
unlock("1111");//里面是你的锁屏密码,仅支持数字解锁,并且需要点击确定键,需要点击确定键的需要自己改一下解锁函数 var friendNumber=145;//这里输入你的好友数,适当输大一点 threads.start(function(){
toast("按音量下键停止")
//启动监听
events.observeKey();
//监听音量下键
events.onKeyDown("volume_down",function(event){
toast("已停止")
exit();
}) }); //启动app
launchApp("支付宝");
waitForActivity("com.eg.android.AlipayGphone.AlipayLogin");
sleep(5000);
var w=text("蚂蚁森林").className("android.widget.TextView").findOne();
var b=w.bounds();
if(w==null){
log("null");
}
//点击蚂蚁森林
if(click(b.centerX(),b.centerY())){
//toast("点击成功");
log("点击成功");
}else{
log("点击失败");
} //收集自己的能量
sleep(5000);
//collectEnergy(); var width=device.width;
var i,j; //盲点收自己的能量
for(i=450;i<=800;){//y方向点击范围
threads.start(function(){
for(j=300;j<width-200;){//x方向点击范围
click(j,i);
j=j+150;
}
});
sleep(1000);
i=i+100;
} toastLog("收集能量完成"); //偷好友能量
sleep(3000);
stealEnergy(friendNumber); toastLog("偷能量完成"); sleep(2000); back();
sleep(2000);
back();
sleep(2000); //关闭应用,仅有root权限下有用
shell("am force-stop com.eg.android.AlipayGphone",true); exit(); //解锁函数
function unlock(password){
var a;
var b;
if (!device.isScreenOn()) {
device.wakeUpIfNeeded();
sleep(2000);
swipe(500,1000,500,100,1000);
for(var i=0;i<password.length;i++){
a=password.charAt(i);
log(a);
sleep(500);
b=text(a).findOne().bounds();
click(b.centerX(),b.centerY());
}
//需要点击确定键的可以在下面加上click(x坐标,y坐标);
toast("解锁成功");
sleep(500);
}
} //收能量
function collectEnergy(){
sleep(2000);
var i=descContains("收集能量").find().size();
toast("可以收集"+i+"个能量");
//descContains("收集能量").exists();
while(i!=0){
b=descContains("收集能量").findOne().bounds();
sleep(1000);
click(b.centerX(),b.centerY());
i--;
sleep(1000);
}
} //找好友的能量
function findFriendEnergy(){
//截图
var img = captureScreen();
//toastLog("开始找色");
//var point = findColor(img, "#1DA06D");
var point = findColorInRegion(img,"#1DA06D", 0, 0, device.width,400);
if(point){
//toastLog("x = " + point.x + ", y = " + point.y);
//点击进去偷能量
click(point.x,point.y+50);
return true;
}else{
//toastLog("没有找到");
return false;
}
} //滑动屏幕找到更多好友
function swipeScreenFirst(){ //gesture(1000,[500,1500],[500,500])
swipe(500,600,500,100,1000);
var i=5;
while(true){
if(desc("查看更多好友").exists()){
desc("查看更多好友").findOne().click();
sleep(2000);
swipe(500,500,500,278,1000);
break;
} if(i==0){
toastLog("你的好友太少无法偷取");
sleep(2000)
back();
sleep(2000);
//关闭应用,仅有root权限下有用
shell("am force-stop com.eg.android.AlipayGphone",true); exit();
} i--;
} } //滑动屏幕
function swipeScreen(){
//滑动一个好友的距离
//gesture(1000,[500,1500],[500,500])
swipe(500,500,500,290,1000); } //偷好友能量
function stealEnergy(friendNumber){
//滑动屏幕,找到查看更多好友进入到好友排行榜
swipeScreenFirst();
sleep(2000); //一个一个偷能量
while(friendNumber!=0){
if(findFriendEnergy()){
sleep(2000);
collectEnergy();
back();
sleep(1000);
swipeScreen();
}else{
swipeScreen();
sleep(1000);
} friendNumber--; } }

具体使用方式见下面录屏:

Auto.js 初试-Android开发JS利器的更多相关文章

  1. [js开源组件开发]js多选日期控件

    js多选日期控件 详情请见:http://www.lovewebgames.com/jsmodule/calendar.html 它的github地址:https://github.com/tianx ...

  2. [js开源组件开发]js手机联动选择地区仿ios 开源git

    js手机联动选择地区 前言:由于网上找到了一个mobiscrool,比较全,但是不开源,只能试用15天,正式版竟然要三千块钱,穷人只能自己动手,写了个只针对弹窗地区选择的. 本站点所有的资源均在git ...

  3. [js开源组件开发]js手机联动选择日期 开源git

    js手机联动选择日期 这里在前面的<js手机联动选择地区>的基础上,改造数据源之后形成的一个日期的选择器,当然你可以使用之前的PC上模式的<日期控件>,它同时也支持手机端,ht ...

  4. [js开源组件开发]js轮播图片支持手机滑动切换

    js轮播图片支持手机滑动切换 carousel-image 轮播图片,支持触摸滑动. 例子见DEMO http://www.lovewebgames.com/jsmodule/carousel-ima ...

  5. [js开源组件开发]js文本框计数组件

    js文本框计数组件 先上效果图: 样式可以自行调整 ,它的功能提供文本框的实时计数,并作出对应的操作,比如现在超出了,点击下面的按钮后,文本框会闪动两下,阻止提交.具体例子可以点击demo:http: ...

  6. [js开源组件开发]js手机端浮层控件,并有多种弹出小提示,兼容pc端浏览器

    js dialog组件,包含alert和confirm的实现 本组件所有的资源均在github上可以查看源代码 GitHub 本dialog的组件的例子请在这里查看 demo dialog js di ...

  7. 【转】Android开发笔记(序)写在前面的目录

    原文:http://blog.csdn.net/aqi00/article/details/50012511 知识点分类 一方面写写自己走过的弯路掉进去的坑,避免以后再犯:另一方面希望通过分享自己的经 ...

  8. [Hybrid App]--Android混合开发,Android、Js的交互

    AndroidJs通信 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !imp ...

  9. Android开发学习之路--Java和Js互相调用

      随着前端的火热,以前开发的快速,越来越多的native app在其中融合了h5,就拿淘宝就是很多的h5组成的,一旦出现什么节日,他都可以不用通过更新app来实现界面的改变,而且android和io ...

随机推荐

  1. gitlab数据迁移至其他gitlb服务器上

    需求: A : 待迁移服务器,上边存有数据 B:接收项目得服务器,本身存在数据 验证方案: 一,搭建gitlab8.15.2 OS:rhel7.4 yum install policycoreutil ...

  2. tp5 auth权限设置

    案例:把所需要的auth类放在一个公共的地方引用,我这里就只是放在了与application同级的extend里面的org所以我在公共控制器里面实例为use \org\Auth; 然后我再公共控制器里 ...

  3. 更改file文件上传默认CSS样式

    前言: 多数时候我们需要表单上传文件,如图片.但是浏览器默认的input[file]样式很不友好, 需要我们自己手动修改. 如图基于bootstrap布局的表单, 但file文件上传样式不敢恭维. & ...

  4. C语言堆栈的区别

    堆(heap)和栈(stack)有什么区别?? 简单的可以理解为: heap:是由malloc之类函数分配的空间所在地.地址是由低向高增长的. astack:是自动分配变量,以及函数调用的时候所使用的 ...

  5. html5-边框属性

    width: 500px;    height: 300px;    background: rgb(122,30,60);    border: 10px solid black;    /*bor ...

  6. uva 1633 Dyslexic Gollum

    题意: 给出n和k,求出长度为n的不包含长度大于等于k的回文串的01字符串的个数. 思路: 如果一个字符串包含长度为k的回文串,那么它肯定包含长度为k-1的回文串,所以考虑第i位的时候,只要前缀中不包 ...

  7. Caterpillar sis service information training and software

    Cat et sis caterpillar heavy duty truck diagnostics repair. Training demonstration allows.cat electr ...

  8. What’s WOYO PDR-007 Paintless Dent Repair Heat Induction?

    when you car body with dent, which tools can fixing this problem? is there a device which with the c ...

  9. mysql03

    查询的列不在同一表中必须使用连接内连接,外链接 -- 输出学生姓名以及对应的年级名称 内连接 select studentName,gradeName from student inner join ...

  10. i2c调试碰到的问题

    i2c eeprom i2cget两次结果不一致 i2cset没成功. device里只看到50,却冒出了51地址. i2ctools是针对8bit地址的,而我们的eeprom都是用16bit add ...