Code Monkey home page Code Monkey logo

accessibilitydemo's Introduction

accessibilityDemo

安卓模拟点击服务工具包

一. 如何使用? 亦可参考demo

  1. 接入module包,创建一个service继承module中的AutoCoreService
  2. manifest文件中声明service
 <service
            android:name="你创建的service包类名"
            android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
            <intent-filter>
                <action android:name="android.accessibilityservice.AccessibilityService" />
            </intent-filter>

            <meta-data
                android:name="android.accessibilityservice"
                android:resource="@xml/accessibility_service_config" />
        </service>
  1. 利用api创建自己的脚本逻辑

二. accessibility 主要API

1. UiApi.isMyNeedPage [判断是否在当前页面]

ps: 以判断是否在手机设置界面为例

String pageStr = "{"
                + "'maxMustMills':5000,"
                +"'maxOptionMills':5000,"
                + "'must':{'text':['设置'],'id':[],'desc':[]},"
                +"'option':{'text':['更多'],'id':[],'desc':[]}"
                + "}";
        UiApi.isMyNeedPage(pageStr);
       

参数说明 : maxMustMills 必要节点最大查找时间,毫秒 maxOptionMills 可选节点最大查找时间,毫秒 must 必要节点, option 可选节点 text 节点文本内容,数组,可填多个 id 节点的资源id,数组,可填多个 desc 节点的描述内容,数组,可填多个

2. UiApi.jumpToNeedPage [前往某个界面]

ps: 例子 [设置->移动网络]

String temp1 = "{"
                + "'maxWClickMSec':1000,"
                + "'click':{'text':'更多'},"
                + "'page':"
                +"{"
                + "'maxMustMills':5000,"
                + "'maxOptionMills':5000,"
                + "'must':{'text':['更多','设置'],'id':[],'desc':[]},"
                + "'option':{'text':[],'id':[],'desc':[]}"
                +"}"
                +     "}";

        String temp2 = "{"
                + "'maxWClickMSec':1000,"
                + "'click':{'text':'移动网络'},"
                + "'page':"
                +"{"
                + "'maxMustMills':5000,"
                + "'maxOptionMills':5000,"
                + "'must':{'text':['移动网络','更多'],'id':[],'desc':[]},"
                + "'option':{'text':[],'id':[],'desc':[]}"
                +"}"
                +     "}";	
		UiApi.jumpToNeedPage(new String[]{temp1,temp2});
       

参数说明 : maxMustMills 必要节点最大查找时间,毫秒 maxOptionMills 可选节点最大查找时间,毫秒 click 需要点击的节点, 支持(text,id,desc)三种方式 page 页面 must 必要节点, option 可选节点 text 节点文本内容,数组,可填多个 id 节点的资源id,数组,可填多个 desc 节点的描述内容,数组,可填多个

3. UiApi类 其他接口
  1. backHome 回home页
  1. back 返回
  2. findNodeByTextWithTimeOut 通过text精确查找节点
  3. findNodeByIdWithTimeOut 通过Id 精确查找节点点
  4. findNodeByDesWithTimeOut 通过des 精确查找节点
  5. findNodeByClsWithTimeOut 通过类名,模糊查找节点,有多个只会返回第一个
  6. clickNodeByTextWithTimeOut 通过text查找节点并点击
  7. clickNodeByIdWithTimeOut 通过id 查找节点并点击
  8. clickNodeByDesWithTimeOut 通过des 查找节点并点击
  9. findNodeByTextAndInput 通过 text查找节点并输入内容
  10. findNodeByIdAndInput 通过id查找节点并输入内容
  11. ......其他自己去看源码

accessibilitydemo's People

Contributors

momoxiaoming 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.