说明
本文提供的代码仅供参考。不建议用于生产环境。
可能有些地方在最新版本的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整理提供
var window = floaty.window(
<card layout_width="match_parent" layout_height="match_parent" cardCornerRadius="8dp" cardElevation="0dp" gravity="center_vertical">
<LinearLayout orientation="vertical" layout_width="wrap_content" layout_height="wrap_content" gravity="left|center">
<EditText layout_width="360px" inputType="number" layout_height="85px" ems="10" hint="手机号码" textSize="15sp"id="EditText1" textColor="#0078FF"/>
<LinearLayout orientation="horizontal" layout_width="wrap_content" layout_height="wrap_content">
<EditText layout_width="260px" inputType="number" layout_height="85px" ems="10" textSize="15sp" hint="验证码" id="EditText2" textColor="#0078FF"/>
<Button layout_width="100px" layout_height="75px" text="发送" id="code" textColor="#0078FF"/>
</LinearLayout>
<LinearLayout orientation="horizontal" layout_width="wrap_content" layout_height="wrap_content">
<Button layout_width="wrap_content" layout_height="80px" text="登入" id="Loginto" textColor="#0078FF"/>
<Button layout_width="wrap_content" layout_height="80px" text="退出" id="exit" textColor="#0078FF"/>
</LinearLayout>
</LinearLayout>
</card>
);
setInterval(() => {}, 1000);
//window.setPosition(160, 360);
window.requestFocus();
window.code.on("click", () => {
toastLog("获取验证码");
});
window.Loginto.on("click", () => {
toastLog("登入");
});
window.exit.on("click", () => {
window.close();
// exit();
});