iapp无障碍服务

用法:
固定模块名为 ays_service 可创建模块 ays_service.myu,代码如下:

//事件方法 on 实时回调变化事件
fn on(e)
//获取事件类型
java(b, ays, "com.iapp.app.ays.gtype", "android.view.accessibility.AccessibilityEvent", e)
//如果事件类型
f(b == 32 || b == 2048){
  //获取事件源的对象节点列表
  java(node, ays, "com.iapp.app.ays.gall", "AccessibilityEvent", e)
  //判断事件来源是不是包名为com.iapp.app的应用
  java(gpn, ays, "com.iapp.app.ays.gpn", "AccessibilityEvent", e)
  f("com.iapp.app" == gpn)
  {
     //判断类名,根据指定的类名进行不同的操作
     java(gcn, ays, "com.iapp.app.ays.gcn", "AccessibilityEvent", e)
     f("com.iapp.app.HomeMian" == gcn)
     {
        //从对象列表搜索文本为“创建”的对象,并点击该对象
        java(b, ays, "com.iapp.app.ays.cktext", "AccessibilityNodeInfo", node, "int", 16, "String", "创建")
     }
     else f("com.iapp.app.HomeAdd" == gcn)
     {
        //根据ID获取指定的节点
        java(b, ays, "com.iapp.app.ays.id", "AccessibilityNodeInfo", node, "String", "com.iapp.app:id/ui_home_add_title")
    //设置节点的文本框输入指定字符
        java(c, ays, "com.iapp.app.ays.enter", "java.util.List", b, "String", "name")
        //根据ID获取指定的节点
        java(b, ays, "com.iapp.app.ays.id", "AccessibilityNodeInfo", node, "String", "com.iapp.app:id/ui_home_add_remark")
    //设置节点的文本框输入指定字符
        java(c, ays, "com.iapp.app.ays.enter", "java.util.List", b, "String", "remark")
        //从对象列表搜索指定ID的对象,并点击该节点对象
        java(b, ays, "com.iapp.app.ays.ckid", "AccessibilityNodeInfo", node, "int", 16, "String", "com.iapp.app:id/ui_home_add_go")
     }
  }
  //释放根源节点
  java(b, ays, "com.iapp.app.ays.re", "AccessibilityNodeInfo", node)
 
}
 
end fn
 
//初始化事件方法 onsc 启动时回调一次
fn onsc()
s pns = "com.iapp.app"
//设置监听指定的包名,可以设置多个包名用逗号隔开如"com.xxx.a,com.xxx.b"
javass(a, null, "com.iapp.app.ays.pns", pns)
//设置相应时间
javass(a, null, "com.iapp.app.ays.nt", 1000)
end fn
 
 
然后 权限配置管理》application配置 将下面的配置粘贴进去:
    <service
            android:name="com.iapp.app.ays"
            android:label="iapp开发工具无障碍辅助功能"
            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/aya_config"/>
        </service>
 
最后,[正式打包发布]打包完成后,安装测试。记得自行去设置》辅助功能》打开我们的服务《iapp开发工具无障碍辅助功能》。
注意:直接在iapp里测试无效。
 
 
更多代码示范:
 
//------静态调用
//获取无障碍功能是否已经授权
java(a, null, "com.iapp.app.ays.isas", "Context", activity)
 
//如果没有授权,可跳转设置界面
java(a, null, "com.iapp.app.ays.goset", "Context", activity)
 
 
//------事件源操作
//获取Context功能类
java(a, ays, "com.iapp.app.ays.gbc")
 
//获取无障碍功能配置信息
java(a, ays, "com.iapp.app.ays.gsi")
 
//设置无障碍功能配置信息
java(b, ays, "com.iapp.app.ays.ssi", "AccessibilityServiceInfo", a)
 
//调用全局事件
//输入值:1. 返回键 2. HOME键 3. 最近打开应用列表 4. 打开通知栏 5. 设置 6. 锁屏
java(a, ays, "com.iapp.app.ays.pga", "int", 1)
 
//获取事件类型
//值:32 打开PopupWindow,Menu,Dialog等的事件  64 显示通知的事件  2048 更改窗口内容的事件  4194304 屏幕上显示的窗口中的事件更改
java(a, ays, "com.iapp.app.ays.gtype", "AccessibilityEvent", e)
 
//获取事件源类的类型
java(a, ays, "com.iapp.app.ays.gcn", "AccessibilityEvent", e)
 
//获取事件源的包名
java(a, ays, "com.iapp.app.ays.gpn", "AccessibilityEvent", e)
 
//获取事件源的是否可用
java(a, ays, "com.iapp.app.ays.ised", "AccessibilityEvent", e)
 
//获取事件源的节点总数
java(a, ays, "com.iapp.app.ays.gsl", "AccessibilityEvent", e)
 
//获取事件源的整数ID
java(a, ays, "com.iapp.app.ays.gwid", "AccessibilityEvent", e)
 
//获取事件源的时间
java(a, ays, "com.iapp.app.ays.gtime", "AccessibilityEvent", e)
 
//释放资源
java(a, ays, "com.iapp.app.ays.re", "AccessibilityEvent", e)
 
 
//------节点的操作
//获取事件源的节点对象列表
java(a, ays, "com.iapp.app.ays.gall", "AccessibilityEvent", e)
 
//获取窗口的对象节点列表,需要Android 4.1及以上才可调用
java(a, ays, "com.iapp.app.ays.gall")
 
//根据序号;获取对象的子节点
java(a, ays, "com.iapp.app.ays.gi", "AccessibilityNodeInfo", node, "int", 0)
 
//获取对象的子节点总数
java(a, ays, "com.iapp.app.ays.gi", "AccessibilityNodeInfo", node)
 
//根据当前焦点向某个方向进行搜索可以获得输入焦点的最近控件
//输入值:33 向上  130 向下  17 向左  66 向右
java(a, ays, "com.iapp.app.ays.focussearch", "AccessibilityNodeInfo", node, "int", 130)
 
//根据文本查询控件,返回节点列表
java(nodelist, ays, "com.iapp.app.ays.text", "AccessibilityNodeInfo", node, "String", "创建")
 
//根据id查询控件,返回节点列表
java(nodelist, ays, "com.iapp.app.ays.id", "AccessibilityNodeInfo", node, "String", "com.iapp.app:id/ui_home_add_go")
 
//根据焦点查询
//输入值:1 输入焦点  2 可访问性焦点
java(a, ays, "com.iapp.app.ays.focus", "AccessibilityNodeInfo", node, "int", 1)
 
//获取节点文本
java(a, ays, "com.iapp.app.ays.gt", "AccessibilityNodeInfo", node)
 
//获取节点类的类型
java(a, ays, "com.iapp.app.ays.gcn", "AccessibilityNodeInfo", node)
 
//获取节点整数ID
java(a, ays, "com.iapp.app.ays.gwid", "AccessibilityNodeInfo", node)
 
//获取节点ID
java(a, ays, "com.iapp.app.ays.gid", "AccessibilityNodeInfo", node)
 
//获取可以在节点上执行的操作
java(a, ays, "com.iapp.app.ays.gal", "AccessibilityNodeInfo", node)
 
//获取节点在屏幕上坐标
java(a, ays, "com.iapp.app.ays.gbis", "AccessibilityNodeInfo", node)
 
//获取父节点在屏幕上坐标
java(a, ays, "com.iapp.app.ays.gbip", "AccessibilityNodeInfo", node)
 
//获取节点的包名
java(a, ays, "com.iapp.app.ays.gpn", "AccessibilityNodeInfo", node)
 
//获取节点的父节点
java(a, ays, "com.iapp.app.ays.gp", "AccessibilityNodeInfo", node)
 
//获取此节点是否可点击
java(a, ays, "com.iapp.app.ays.isck", "AccessibilityNodeInfo", node)
 
//获取此节点是否已启用
java(a, ays, "com.iapp.app.ays.ised", "AccessibilityNodeInfo", node)
 
//获取此节点是否已选中
java(a, ays, "com.iapp.app.ays.iscd", "AccessibilityNodeInfo", node)
 
//获取这个节点是否被聚焦
java(a, ays, "com.iapp.app.ays.isfd", "AccessibilityNodeInfo", node)
 
//获取此节点是否可以长时间点击
java(a, ays, "com.iapp.app.ays.islck", "AccessibilityNodeInfo", node)
 
//获取此节点是否是密码
java(a, ays, "com.iapp.app.ays.ispd", "AccessibilityNodeInfo", node)
 
//获取节点是否可滚动
java(a, ays, "com.iapp.app.ays.isse", "AccessibilityNodeInfo", node)
 
//获取是否选择此节点
java(a, ays, "com.iapp.app.ays.issd", "AccessibilityNodeInfo", node)
 
 
 
//根据文本查询;模拟控件点击控件
java(a, ays, "com.iapp.app.ays.cktext", "AccessibilityNodeInfo", node, "int", 16, "String", "创建")
 
//根据ID查询;模拟控件点击控件
java(a, ays, "com.iapp.app.ays.ckid", "AccessibilityNodeInfo", node, "int", 16, "String", "com.iapp.app:id/ui_home_add_go")
 
//根据焦点查询;模拟控件点击控件
//输入值:1 输入焦点  2 可访问性焦点
java(a, ays, "com.iapp.app.ays.ckfocus", "AccessibilityNodeInfo", node, "int", 16, "int", 1)
 
 
    /.
      模拟执行操作
      1 将输入焦点输入到节点的操作
      16 点击节点信息的动作
      32 长时间点击节点的动作
      32768 操作来粘贴当前的剪贴板内容
     ./
//开始模拟控件点击
//输入节点列表
java(b, ays, "com.iapp.app.ays.ck", "java.util.List", nodelist, "int", 16)
文章地址:漫夜 » iapp无障碍服务
漫夜网QQ群
扫描二维码加入QQ群,一起在线交流!
300+人已加过群
分享到: