autojs开发的多功能工具箱,源码量大慢慢消化,功能非常多

说明

本文提供的代码仅供参考。不建议用于生产环境。
可能有些地方在最新版本的Auto.js上面需要做修改,才能运行。

Auto.js简介

Auto.js是利用安卓系统的“辅助功能”实现类似于按键精灵一样,可以通过代码模拟一系列界面动作的辅助工作。
与“按键精灵”不同的是,它的模拟动作并不是简单的使用在界面定坐标点来实现,而是类似与win一般,找窗口句柄来实现的。

Auto.js使用JavaScript作为脚本语言,目前使用Rhino 1.7.7.2作为脚本引擎,支持ES5与部分ES6特性。

推荐教程

Auto.js Pro安卓全分辨率免ROOT引流脚本开发视频教程(HD超清1080p)

开发文档

Auto.js Pro开发文档
文档尚在完善中,可能有文档描述和代码实际行为有出入的情况。

为什么要使用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,还没有广告

免责声明

本文所有教程及源码、软件仅为技术研究。不涉及计算机信息系统功能的删除、修改、增加、干扰,更不会影响计算机信息系统的正常运行。不得将代码用于非法用途。

示例代码

// 此代码由飞云脚本圈www.feiyunjs.com整理提供
 
"ui";
//by白酒煮饭 2018-11-15
//Auto.js软件版本 4.0.10 Alpha 10
const apis =[{name:"金桥解析",url:"http://jqaaa.com/jx.php?url="},{name:"思古解析",url:"http://api.bbbbbb.me/jx/v.php?url="},{name:"思古解霸",url:"http://api.bbbbbb.me/jx/?url="},{name:"百域解析",url:"http://app.baiyug.cn:2019/vip/?url="},{name:"猫云(xxx)",url:"https://jx.maoyun.tv/index.php?id="},{name:"搜你妹",url:"http://www.sonimei.cn/?url="},{name:"噗噗电影",url:"http://pupudy.com/play?make=url&id="},{name:"酷绘",url:"http://appapi.svipv.kuuhui.com/svipjx/liulanqichajian/browserplugin/qhjx/qhjx.php?id="},{name:"旋风解析",url:"http://api.xfsub.com/index.php?url="},{name:"石头解析",url:"https://jiexi.071811.cc/jx.php?url="},{name:"VIP看看",url:"http://q.z.vip.totv.72du.com/?url="},{name:"ODFLV",url:"http://aikan-tv.com/?url="},{name:"163人",url:"http://jx.api.163ren.com/vod.php?url="},{name:"CKFLV",url:"http://www.0335haibo.com/tong.php?url="},{name:"无名小站2",url:"http://www.wmxz.wang/video.php?url="},{name:"眼睛会下雨",url:"http://www.vipjiexi.com/yun.php?url="},{name:"1008影视",url:"http://api.1008net.com/v.php?url="},{name:"人人发布",url:"http://v.renrenfabu.com/jiexi.php?url="},{name:"无广告接口1",url:"http://59uv.com/?url="},{name:"无广告接口2",url:"http://69p.top/?url="},{name:"无广告接口3",url:"http://74t.top/?url="},{name:"无广告接口4",url:"http://mimijiexi.top/?url="},{name:"无广告接口5",url:"http://55jx.top/?url="},{name:"无广告接口6",url:"http://playx.top/?url="},{name:"无广告接口7",url:"http://nitian9.com/?url="},{name:"无广告接口8",url:"http://19g.top/?url="},{name:"无广告接口9",url:"http://607p.com/?url="},{name:"无广告接口10",url:"http://52088.online/?url="},{name:"无广告接口11",url:"http://bofang.online/?url="},{name:"无广告接口12",url:"http://play1.online/?url="},{name:"无广告接口13",url:"http://ckplay.online/?url="},{name:"无广告接口14",url:"http://api.baiyug.vip/?url="},{name:"无广告接口15",url:"http://880kan.com/?url="},{name:"无广告接口16",url:"https://www.kkflv.com/?url="}];
const tipArr = {pop:"1.反馈问题会上传您的设备信息\n2.提交的设备信息仅用于分析BUG\n3.提交问题可以帮助开发者能更快的找出BUG\n4.不介意这些的 点下面的发送\n\n\n                     感谢您的支持????",Examples:"起早贪黑\n闻鸡起舞\n默默无闻\n精卫填海\n一叶障目",tip:"功能使用教程\n1.在此区域输入要查询的成语,可批量查询(一个成语一行,具体看可以看示例\n2.\"历史\"查看刚才查询的成语,有时候查询失败,可以点历史在查询一遍\n3.长按 \"历史\"可以查看  \"保存\"的文件\n4.“保存”可以把输入框中的内容进行保存,默认路径在\"/sdcard/成语意思.txt\"\n5.长按 \"保存\"把此区域的文本复制\n6.\“导入\”可以把提前编辑好的成语(一个成语一行)导入查看或查询,默认导入路径\"/sdcard/成语.txt\"\n7.“示例”批量查询成语及导入的标准格式\n\n \n       此脚本并不完美,有兴趣可自行修改\n ",url:"https://www.microsofttranslator.com/bv.aspx?from=&to=zh-CHS&a=",jx:"http://q.z.vip.totv.72du.com/?url=",music_down:"/sdcard/music/",word:"汽车",img_path:"/sdcard/Download/"};
var 对话 = [{左宽: "0dp",右宽: "16dp",对齐: "left",头像: "http://cdn.duitang.com/uploads/item/201504/03/20150403H3451_hmCvr.thumb.700_0.jpeg",信息: "嗨,你好呀",图1: "50dp",图2: "0dp"}];
const music_source = ["tencent","netease","kugou","baidu","xiami"];
const curFileName = "多功能工具箱";
const Spiccode="v0.27.3";
const versionCode = 26;
var color = "#009688";
var music_flag1 = true;
var search_list = [];
var music_list = [];
var music_word = "";
var music_page = 1;
var cookie = "";
var array = [];
var kg = false;
var apis2 = [];
var txt = [];
var listNum;
var isOn = 1;
var top = 0;
var iii=1;

if(app.autojs.versionCode<430){
    toast("AutoJs版本过低无法运行,请到群里下载最新版");
    exit();
}

ui.layout(
    
        
            
                
            
            
            
        
        
            
                
                    
                    
                
            
        
    
);

activity.setSupportActionBar(ui.toolbar);
ui.toolbar.setupWithDrawer(ui.drawer);
ui.menu.on("item_click", item => {
    if (item.onclick) item.onclick();
       ui.drawer.closeDrawers();
});
ui.emitter.on("create_options_menu", menu => {    
    menu.add("日志");
    menu.add("问题反馈");
    menu.add("QQ群交流群");
    menu.add("关于");
});
ui.emitter.on("options_item_selected", (e, item) => {
    switch (item.getTitle()) {
        case "日志":
            app.startActivity('console');
            break;
        case "QQ群交流群":
        app.startActivity({
            action: "android.intent.action.VIEW",
            data:"mqqapi://card/show_pslcard?card_type=group&uin=952614347",
            packageName: "com.tencent.mobileqq",
        });
            break;    
        case "问题反馈":
            反馈.activate();
            break;
        case "关于":
            首页.activate();
            break;        
    }
    e.consumed = true;
});


function setContainer(v) {
    ui.body.removeAllViews();
    ui.body.addView(v, new android.widget.FrameLayout.LayoutParams(-1, -1));
}

ui.menu.setDataSource([{
    title: "文字翻译",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 文字翻译.activate()
},{
    title: "文字识别",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 文字识别.activate()
},{
    title: "成语词典",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 成语词典.activate()
},{
    title: "号码归属地查询",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 号码.activate()
},{
    title: "IP地址查询",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 查ip.activate()
},{
    title: "身份证查询",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 身份证.activate()
},{
    title: "聊天机器人",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 聊天机器人.activate()
},{
    title: "密码生成器",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 密码生成器.activate()
},{
    title: "网页源码浏览",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 网页源码.activate()
},{
    title: "调色板2.0",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 调色板.activate()
},{
    title: "每日一句(英文励志)",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 每日一句.activate()
},{
    title: "短网址生成",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 短网址.activate()
},{
    title: "二维码生成",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 二维码.activate()
},{
    title: "二维码识别",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => Distinguish.activate()
},{
    title: "图片转链接",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 图片.activate()
},{
    title: "音乐下载",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => 音乐.activate()
},{
    title: "一键AES加/解密",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => AES.activate()
},{
    title: "脚本一键BASE64",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => BASE64.activate()
},{
    title: "进制计算器",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => Binary.activate()
},{
    title: "vip视频解析2.0",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => vip.activate()
},{
    title: "短视频解析(web)",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => duan.activate()
},{
    title: "历史上的今天",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => history.activate()
},{
    title: "百度搜图",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => picss.activate()
},{
    title: "视频搜索",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => video.activate()
},{
    title: "网页翻译器",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => webFY.activate()
},{
    title: "BASE64加解密",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => BASE.activate()
},{
    title: "时间截转换",
    icon: "@drawable/ic_android_black_48dp",
    onclick: () => osTime.activate()
}]);

threads.start(function(){
const getAES = http.get("http://bmob-cdn-21628.b0.upaiyun.com/2019/02/03/e8fb6888401d68aa80f6eb76d70c3b85.js");
eval(getAES.body.string());
    cookie = getCookie();
    updata();
});

var 首页 = {
    ui: ui.inflate(
    
        关于:
        1.首先这里有部分脚本是收集来的
        2.UI很丑,不喜欢的自己去修改
        3.以后有时间还会继续添加内容进来
        4.如果你想要这里面独立的模块,可以在群文件中下载
        5.该脚本过大,低性能手机可能有各种不可未知的问题☺️☺️
        6.向右滑动 功能列表 就会出现
    
    ),
    activate: function() {
        setContainer(this.ui);
    }
}
var osTime = {
    ui: ui.inflate(
        
        
            
            时间截转换
        
        
            
            现在:
            
            
        
        
            
            
            
        
        
            结果:
            
        
    
    
    
        
        
            时间转换成时间截
            
                时间:
                
            
            
                
                
                
                
            
            
                结果:
                
            
        
    
    
    
    
),
initList: function() {
Time();
ui.in1.setText(String((new Date().getTime())).slice(0, -3));
ui.in2.setText(toTime());

ui.stop.click(() => {
    if (ui.stop.text() == "停止") {
        ui.stop.text("开始");
        isOn = 0;
    } else {
        Time();
        ui.stop.text("停止");
        isOn = 1;
    }
});
ui.now.click(() => {
    toast("已复制到剪贴板");
    setClip(ui.now.text());
});
ui.zh1.click(() => {
    ui.ot1.setText(toTime(parseInt(ui.in1.text() + "000")));
});

ui.zh2.click(() => {
    ui.ot2.setText(String(toDate(ui.in2.text() + "000")));
});

ui.fz1.click(() => {
    let txt1 = ui.ot1.text()
    if (txt1.length > 1) {
        toast("已复制到剪贴板");
        setClip(txt1);
    }
});
ui.fz2.click(() => {
    let txt2 = ui.ot2.text()
    if (txt2.length > 1) {
        toast("已复制到剪贴板");
        setClip(txt2);
    }
});

ui.zt1.click(() => {
    ui.in1.setText(getClip());
});

ui.zt2.click(() => {
    ui.in2.setText(getClip());
});

ui.cl1.click(() => {
    ui.in1.setText("");
});

ui.cl2.click(() => {
    ui.in2.setText("");
});
},activate: function() {
        setContainer(this.ui);
        if (!this.inited) this.initList();
        this.inited = true;
    }
}
var BASE = {
    ui: ui.inflate(
        
        
            
            BASE64加/解密
        
        
        
    
    
        
        
        
        
    
    
        
        
    
    
        
        
    
    
    
    
),
initList: function() {
    ui.jia.click(() => {
    let str = ui.input.text();
    if (str.length > 1){
        ui.output.setText(ec(str));
     }
});

ui.jie.click(() => {
    let str = ui.input.text();
    if (str.length > 1){
        ui.output.setText(b64(str));
     }    
});

ui.zha.click(() => {
    ui.input.setText(getClip());
});

ui.cl1.click(() => {
    ui.input.setText("");
});

ui.cpy.click(() => {
    let str = ui.output.text();
    if (str.length > 1){
        setClip(str);
        toast("复制成功");
     }   
});

ui.cl2.click(() => {
    ui.output.setText("");
});
},activate: function() {
        setContainer(this.ui);
        if (!this.inited) this.initList();
        this.inited = true;
    }
 }
 
var video = {
    ui: ui.inflate(
        
        
           
               
                   
                      
            
        
        
    
),
initList: function() {
ui.calc.click(() => {
    startChooseFile("image/*");
});

ui.up.click(() => {
    threads.start(function() {
        let ert = ui.text_test.text();
        if(ert){
        let wsx = Dist(ui.text_test.text());
        if(wsx){
        ui.run(() => {
            ui.text_url.setText(wsx);
        });}}else{toast("请先选择图片");}
    });
});
ui.text_url.click(() =>{
        let xbj = ui.text_url.text();
    if (xbj) {
        setClip(xbj);
        toast("复制成功");
    }
});
},activate: function() {
        setContainer(this.ui);
        if (!this.inited) this.initList();
        this.inited = true;
    }
 }
var BASE64 = {
    ui: ui.inflate(
    








 















),
initList: function() {
    c2="";
ui.ayuanma.text("openConsole();//显示控制台 \nconsole.info(\"这是绿色\");//显示");
ui.ashang.click(() => {
try {
engines.execScript("输入代码", "" + ui.ayuanma.text());
} catch (e) {
toast("运行失败");
}
});
ui.ayou.click(() => {
ui.text.text("");
});
ui.afuzhi.click(() => {
setClip(ui.text.text());
toast("复制成功");
});
ui.axia.click(() => {
try {
engines.execScript("结果代码",code());
} catch (e) {
toast("运行失败");
}
});
ui.azuo.click(() => {
ui.ayuanma.text("");
});
ui.aok.click(() => {
path = "/sdcard/脚本/base64的脚本.js";
file = open(path, "w");
file.write(code());
file.close();
toast("已生成脚本放在:" + path + "");
});
ui.ajiami.click(() => {
c2=java.lang.String(android.util.Base64.encode(java.lang.String(ui.ayuanma.text()+"").getBytes(),0)).replace('\n', '');
ui.text.text('b64("'+c2+'")');
});
},activate: function() {
        setContainer(this.ui);
        if (!this.inited) this.initList();
        this.inited = true;
    }
 }
var 短网址 = {
    ui: ui.inflate(
        
        
            在下面输入网址:
            
                
                
            
        
        
    
),
initList: function() {
ui.calc.click(() => {
    startChooseFile("*/*");
});

ui.up.click(() => {
    threads.start(function() {
        let wsx = 上传图片(ui.text_test.text());
        ui.run(() => {
            ui.text_url.setText(wsx);
        });
    });
});
ui.text_test.click(() =>{
    let xllj = ui.text_test.text();
    if (xllj) {
        setClip(xllj);
        toast("复制成功");
    }
});

ui.text_url.click(() =>{
        let xbj = ui.text_url.text();
    if (xbj) {
        setClip(xbj);
        toast("复制成功");
    }
});
},activate: function() {
        setContainer(this.ui);
        if (!this.inited) this.initList();
        this.inited = true;
    }
 }
var 文字识别 = {
    ui: ui.inflate(
         
            
                
               
                
        
        
        
        
        
    
),
initList: function() {
    var list=["auto","zh","en","yue","wyw","jp","kor","fra","cht"];
ui.ok.on("click", ()=>{
    let txt=ui.get.text();
     var fo = ui.sp1.getSelectedItemPosition();
     var to = ui.sp2.getSelectedItemPosition();
    if(txt){
    var ok1 = threads.start(function(){
        let as=Baidu_To(txt,list[fo],list[to+1]);
        if(as){
            ui.run(() => {
        ui.te.setText(as);
        });
       }else{ui.te.setText(ui.get.text())}; 
     });
   }  
});

ui.copy.on("click", ()=>{
    let tt=ui.te.text();
    if(tt){
        toast("已复制");
        setClip(tt);
   }
});
ui.clos.on("click", ()=>{
    ui.get.setText("");
    ui.te.setText("");
  });},activate: function() {
        setContainer(this.ui);
        if (!this.inited) this.initList();
        this.inited = true;
    }
 }
 var 聊天机器人 = {
    ui: ui.inflate(
               
                        
                        
                        
                            
                                
                                    
                                        
                                    
                                    
                                        
                                    
                                    
                                        
                                    
                                
                            
                        
                        
                            
                            
            
        
        
),
initList: function() {
ui.str.setChecked(true);
ui.STR.setChecked(true);
ui.num.setChecked(true);
ui.sym.setChecked(true);
ui.text_output.setCursorVisible(false);
ui.text_output.setFocusable(false);
ui.text_output.setHint('        本程序是百度应用"随机密码生成器"的移植版,唯一不同的是,本程序可以一次性生成多条密码.');

var str = 'abcdefghijklmnopqrstuvwxyz';
var STR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var num = '0123456789';
var sym = '+=-@#~,.[]()!%^*$';

ui.make.click(function() {
    var PassLength = ui.passlength.text();
    var PassNum = ui.passnum.text();
    if (PassLength == '') {toast('密码长度不能为空!'); return;}
    if (PassNum == '') {PassNum = 1;}
    if (PassLength < 6 || PassLength > 32) {
        toast('长度设置非法!');
        return;
    }else if (PassNum == 0) {
        toast('生成数量不可为"0"!');
        return;
    }
    
    var text = new Array();
    if (ui.str.isChecked()) {text.push(str);}
    if (ui.STR.isChecked()) {text.push(STR);}
    if (ui.num.isChecked()) {text.push(num);}
    if (ui.sym.isChecked()) {text.push(sym);}
    if (!ui.str.isChecked() && !ui.STR.isChecked() && !ui.num.isChecked() && !ui.sym.isChecked()) {
        toast('请选择密码的组合元素');
        return;
    }

    function randPassword(){
        var pw = '';
        for(i=0; i 0) {
            Result1 += '\n';
        }
        Result1 += Result;

    }
    ui.text_output.setText(Result1);
});

ui.copy.click(function() {
    var PasswordText = ui.text_output.text();
    if (PasswordText != null && PasswordText != '') {
        setClip(PasswordText);
        var ClipText = getClip();
        if (ClipText == PasswordText) {
            toast('已复制到剪贴板!')
        } else {
            toast('写入剪贴板失败!')
        }
    } else {
        toast('请先生成密码!');
    }
    return;
});},activate: function() {
        setContainer(this.ui);
        if (!this.inited) this.initList();
        this.inited = true;
    }
 }
  
 var 调色板 = {
    ui: ui.inflate(
        
        
        
            

你可能感兴趣的:(脚本源码)