-
Notifications
You must be signed in to change notification settings - Fork 225
Home
Ven edited this page Aug 13, 2023
·
18 revisions
allprojects {
repositories {
//添加JitPack仓库
maven { url 'https://jitpack.io' }
}
}dependencies {
//添加依赖
implementation 'com.github.ven-coder:assists:1.0.1'
}一定要在主模块中注册服务,不然进程被杀服务也会自动被关闭需要再次开启
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.ven.assists.simple">
<application
android:name="com.ven.assists.simple.App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<!-- 添加以下代码 -->
<service
android:name="com.ven.assist.AssistsService"
android:enabled="true"
android:exported="true"
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/assists_service" />
</service>
</application>
</manifest>实现onImpl(collector: StepCollector)接口,通过collector.next()实现步骤逻辑
class OpenWechat:StepImpl {
override fun onImpl(collector: StepCollector) {
collector.next(1) {
//步骤1逻辑
//打开微信
Intent().apply {
addCategory(Intent.CATEGORY_LAUNCHER)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
component = ComponentName("com.tencent.mm", "com.tencent.mm.ui.LauncherUI")
Assists.service?.startActivity(this)
}
//步骤1执行完,紧接执行步骤2
StepManager.execute(this::class.java, 2)
}.next(2) {
//步骤2逻辑
//查找通讯录按钮
UIOperate.findByText("通讯录").forEach {
//获取到按钮后执行其他逻辑
}
}
}
}StepManager.register(OpenWechat::class.java)执行前请确保无障碍服务已开启,开始执行请使用beginExecute(),后续的步骤执行请使用execute()方法
//从步骤1开始执行
StepManager.beginExecute(OpenWechat::class.java, 1)📥直接下载或扫码下载