说明
本文提供的代码仅供参考。
可能有些地方在最新版本的Auto.js上面需要做修改,才能运行。
Auto.js简介
Auto.js是利用安卓系统的“辅助功能”实现类似于按键精灵一样,可以通过代码模拟一系列界面动作的辅助工作。
与“按键精灵”不同的是,它的模拟动作并不是简单的使用在界面定坐标点来实现,而是类似与win一般,找窗口句柄来实现的。
Auto.js使用JavaScript作为脚本语言,目前使用Rhino 1.7.7.2作为脚本引擎,支持ES5与部分ES6特性。
开发文档
Auto.js Pro开发文档优化版
文档尚在完善中,可能有文档描述和代码实际行为有出入的情况。
模板、样式、generator来自Node.js。
为什么要使用Auto.js Pro开发脚本,有什么特点?
吸引我使用Auto.js Pro的原因有很多。最主要的几个原因是:
- Auto.js Pro能开发免ROOT的安卓脚本
- Auto.js Pro基于节点操作,能开发全分辨率的脚本,自动适配各种安卓机型
- Auto.js Pro丰富的UI组件,能自定义各种样式的安卓界面
- Auto.js Pro使用的javascript的语法比较优雅,代码可读性强
- Auto.js Pro的命令库非常的丰富,接口比较多
- Auto.js Pro脚本文件体积比较小。1000行的代码,打包后的apk文件只有3-5M,还没有广告
推荐教程
Auto.js Pro安卓全分辨率免ROOT引流脚本开发教程
示例代码
auto();//授权auto.js
//基础配置
var dianzancishu = 0;
var dianzanshijian = 1000;
var denglu_cishu = 0;
xuanze_xb = "男";//想看到的用户 全部、女、男
xuanze_sj = "15分钟"; //出现的时间 15分钟 1小时 1天
xuanze_nl = "全部";//出现的时间 15分钟 1小时 1天
xuanze_xz = "不限";//12星座
xuanze_vip = 0;//是否看会员 0=不看,1=看
dengdai = 5;//默认5秒点赞一次
wait_time = 1000*dengdai;//1秒
//此代码由飞云脚本圈整理提供(www.feiyunjs.com)
main();
function main(){
momozhuye();
}
function momozhuye(){
if(text('附近动态').exists()&&text('附近的人').exists()&&text('附近直播').exists()){
toast('陌陌首页');
//sleep(1000);
附近的人 = className('android.view.ViewGroup').find()[6];
click(附近的人.bounds().centerX(),附近的人.bounds().centerY());
sleep(2000);
click(975,530);//点击筛选
while(1){
sleep(2000);
if(text('筛选').exists()){
if(xuanze_xb=='女') click(339,583);
if(xuanze_xb=='男') click(587,583);
sleep(1000);
if(xuanze_sj=="3天") click(823,836);
if(xuanze_sj=="1天") click(605,836);
if(xuanze_sj=="1小时") click(336,836);
if(xuanze_sj=="15分钟") click(62,836);
sleep(1000);
if(xuanze_vip==0){
if(className('android.widget.CompoundButton').findOne().checked()){
click(className('android.widget.CompoundButton').findOne().bounds().centerX(),className('android.widget.CompoundButton').findOne().bounds().centerY());
}
}else{
if(!className('android.widget.CompoundButton').findOne().checked()){
click(className('android.widget.CompoundButton').findOne().bounds().centerX(),className('android.widget.CompoundButton').findOne().bounds().centerY());
}
}
sleep(1000);
//点击完成
text('完成').click();
break;
}
}
sleep(3000);
//收缩上面的菜单栏
if(text('附近正在线的人').exists()){
swipe(500,478+210,500,72,800);//收缩导航栏
}else{
swipe(500,478,500,72,800);
}
sleep(2000);
flag = true;
while(flag){
sleep(3000);
//检测附近用户是否加载
if(id('com.immomo.momo:id/userlist_item_tv_name').exists()&& !text('已展示所有筛选结果,可选择其他筛选项').exists()){
list = id('com.immomo.momo:id/userlist_item_tv_name').find();
list.forEach(child=>{
if(child.bounds().centerY()>1590){
sleep(1000);
swipe(500,497,500,252,1000);//每次执行完滑动一次
}
if(child.bounds().width()>600){
toastLog('有广告:'+child.text());
}else{
click(child.bounds().centerX(),child.bounds().centerY());
text('对话').waitFor();
swipe(500,1000,500,0,1000);
sleep(2000);
if(id("feed_like_view").exists()){
sleep(1000);
click(id("feed_like_view").find()[0].bounds().centerX(),id("feed_like_view").find()[0].bounds().centerY());
sleep(2000);
dianzancishu++;
//当前已经点赞
toastLog("用户:"+child.text()+"|点赞成功,当前点赞次数:"+dianzancishu);
}else{
toastLog("当前用户没有动态");
}
back();
sleep(wait_time);
}
});
}else if (text('已展示所有筛选结果,可选择其他筛选项').exists()){
toastLog('切换账号了');
exit();
}else{
//没有加载数据
toastLog('附近的人没有数据加载');
continue;
}
}
}
}
本文介绍Auto.jsPro,一种基于节点操作的安卓脚本开发工具,支持全分辨率免ROOT设备,采用JavaScript语法,适用于自动化任务如点赞、筛选等。
7547

被折叠的 条评论
为什么被折叠?



