Giter Site home page Giter Site logo

abllib's Introduction

Abllib

Demo:https://github.com/Levine1992/Abllib

AccessibilityService无障碍服务库,一行代码启用,快速开发复杂的自动操作业务

AccessibilityService可以帮助我们做一些自动操作手机的动作,像微信自动抢红包、各种应用市场的自动安装功能就是利用的AccessibilityService服务, 利用这个服务我们可以做更多有意思的事,但是直接继承这个服务,要实现一些复杂点的业务逻辑就很麻烦,所以写了这个库。其实我看这些库介绍最烦人就是罗里吧嗦 说一大堆不进入主题的,回头看下,自己就是那个索黑,不啰嗦进主题

引用

project build.gradle中添加

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

app build.gradle中添加

dependencies {
    ...
    implementation 'com.github.Levine1992:Abllib:V1.0'
}

初始化一些配置

AblConfig.Builder()
                .setLogTag("123456")//logtag,不设置默认是abllib
                .setStepMsgDelayMillis(2000)//步骤延迟时间
                .setFindViewMillisInFuture(10000)//寻找界面超时时间
                .setFindViewCountDownInterval(200)//寻找界面间隔时间
                .build().init();

使用说明

新建具体的自动操作的步骤器继承AblStepBase,如果自动操作业务多可以分开多建几个,区分开便于维护,但是步骤的id最好不要重复

public class TestAblStep1 extends AblStepBase {
    @Override
    public void onStep(int step, Message msg) {
        switch (step) {
            case AblSteps.STEP_1://步骤1
                AblViewUtil.findById(
                        "luoyi.android.com.abldemo:id/btn_3",//传入需要获取抓取的界面的id
                        0,//由于抓到的界面有可能有多个所以传入要获取第几个,一般0就可以
                        new AniCallBack() {//回调
                            @Override
                            public void succ(AccessibilityNodeInfo info) {
                                info.performAction(AccessibilityNodeInfo.ACTION_CLICK);//抓到后执行点击界面操作
                                AblStepHandler.sendMsg(AblSteps.STEP_2);//执行步骤2
                            }

                            @Override
                            public void fail() {//处理抓取失败逻辑

                            }
                        }
                );
                break;
            case AblSteps.STEP_2://步骤2
                AblViewUtil.back();//返回
                AblStepHandler.sendMsg(AblSteps.STEP_1);
                break;
        }
    }
public class TestAblStep2 extends AblStepBase {
    @Override
    public void onStep(int step, Message msg) {
        switch (step) {
            case AblSteps.STEP_3://步骤3
                
                break;
            case AblSteps.STEP_4://步骤4
                
                break;
        }
    }

初始化这些步骤器

AblStepHandler.getInstance().initStepClass(new TestAblStep1(),new TestAblStep2());

执行

AblStepHandler.getInstance().setStop(false);//开启步骤器
AblStepHandler.sendMsg(AblSteps.STEP_1);//执行步骤,如果设置步骤间隔时间为2000,则会延迟两秒执行

over

有问题欢迎issues

或者wechat 1483232332

wechat

如果你觉得好,对你有过帮助,请给我一点打赏鼓励吧,一分也是爱呀!

alipaywechatpay

abllib's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.