说明

本文提供的代码仅供参考。不建议用于生产环境。
可能有些地方在最新版本的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)
"ui";
ui.layout(
<frame>
<relative
    layout_width="match_parent"
    layout_height="match_parent"
    background="#ff0000"
    >
    <button
        id="@+id/button_center"
        layout_width="wrap_content"
        layout_height="wrap_content"
        layout_centerInParent="true"
        text="center"/>
    <button
        id="@+id/button_above"
        layout_width="wrap_content"
        layout_height="wrap_content"
        layout_above="@+id/button_center"
        layout_centerInParent="true"
        text="above"/>
    <button
        id="@+id/button_below"
        layout_width="wrap_content"
        layout_height="wrap_content"
        layout_below="@+id/button_center"
        layout_centerInParent="true"
        text="below"/>
    <button
        id="@+id/button_left"
        layout_width="wrap_content"
        layout_height="wrap_content"
        layout_toLeftOf="@+id/button_center"
        layout_centerVertical="true"
        text="left"/>
    <button
        id="@+id/button_right"
        layout_width="wrap_content"
        layout_height="wrap_content"
        layout_toRightOf="@+id/button_center"
        layout_centerVertical="true"
        text="right"/>
</relative>
</frame>
);

更多推荐

autojs脚本引擎编写的UI相对布局代码免费开源