首汽约车自动抢单功能和源代码

2023-10-31 15:40

本文主要是介绍首汽约车自动抢单功能和源代码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

首汽抢单功能的实现基于AccessibilityService

首汽抢单

package com.gl.accessibilityservice.serviceimport android.accessibilityservice.AccessibilityService
import android.accessibilityservice.GestureDescription
import android.accessibilityservice.GestureDescription.StrokeDescription
import android.annotation.SuppressLint
import android.graphics.Path
import android.util.Log
import android.view.accessibility.AccessibilityEvent@SuppressLint("NewApi")
class Accessibility : AccessibilityService() {private val TAG = "TAG"var top_type = ""var start_distance = ""var end_distance = ""var start_address = ""var end_address = ""var tapX0 = 0var tapY0 = 0var tapX1 = 0var tapY1 = 0var isClick = falsevar isStart_distance = falsevar isEnd_distance = falseoverride fun onServiceConnected() {super.onServiceConnected()}override fun onAccessibilityEvent(event: AccessibilityEvent?) {when (event?.eventType) {AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED -> {if (isClick) isClick = falseif (isStart_distance) isStart_distance = falseif (isEnd_distance) isEnd_distance = falseLog.d(TAG, "onAccessibilityEvent: ...........................")val list =event.source.findAccessibilityNodeInfosByViewId("com.ichinait.gbdriver:id/tv_scramble_order")for (info in list) {if (info.text == "抢") {// "抢"坐标val boundsInScreen = info.toString().substring("boundsInScreen: Rect", ";")tapX0 = boundsInScreen.substring("(", ",").toInt()tapY0 = boundsInScreen.substring(", ", " -").toInt()tapX1 = boundsInScreen.substring("- ", ",").toInt()tapY1 = boundsInScreen.substring("- ", ")").substring(", ").toInt()// 用车时间val list_top_type =event.source.findAccessibilityNodeInfosByViewId("com.ichinait.gbdriver:id/tv_rob_top_type")for (topType in list_top_type) {top_type = topType.text.toString()Log.d(TAG, top_type)}// 起点地址val list_start_address =event.source.findAccessibilityNodeInfosByViewId("com.ichinait.gbdriver:id/tv_rob_start_address")for (startAddress in list_start_address) {start_address = startAddress.text.toString()Log.d(TAG, start_address)}// 终点地址val list_end_address =event.source.findAccessibilityNodeInfosByViewId("com.ichinait.gbdriver:id/tv_rob_end_address")for (endAddress in list_end_address) {end_address = endAddress.text.toString()Log.d(TAG, end_address)}// 抢单逻辑while (!isClick) {if (!isStart_distance) {// 起点val list_start_distance =event.source.findAccessibilityNodeInfosByViewId("com.ichinait.gbdriver:id/tv_rob_start_distance")for (startDistance in list_start_distance) {if (startDistance.text != "···") {start_distance = startDistance.text.toString()isStart_distance = true}}}if (!isEnd_distance) {// 终点val list_end_distance =event.source.findAccessibilityNodeInfosByViewId("com.ichinait.gbdriver:id/tv_rob_end_distance")for (endDistance in list_end_distance) {if (endDistance.text != "···") {end_distance = endDistance.text.toString()isEnd_distance = true}}}if (isStart_distance && isEnd_distance) {isClick = trueLog.d(TAG, start_distance)Log.d(TAG, end_distance)// 根据用户输入设定处理点击逻辑// 判断用车时间if (top_type == "即时用车") {// 判断起点与终点距离(即时用车)if (kmToM(start_distance) <= 2000 && kmToM(end_distance) >= 5000) {Log.d(TAG, "抢")// 抢tap((tapX0 + tapX1) / 2, (tapY0 + tapY1) / 2)} else if (kmToM(start_distance) <= 3500 && kmToM(end_distance) >= 15000) {Log.d(TAG, "行程远,抢")// 抢tap((tapX0 + tapX1) / 2, (tapY0 + tapY1) / 2)} else {// 起点或终点距离不合适,不抢Log.d(TAG, "不抢")tap(100, 100)}} else {Log.d(TAG, "非即时用车不抢")tap(100, 100)}}}}}}}}private fun kmToM(s: String): Int {var m = 0if (s.substring(s.length - 2, s.length) == "km") {val a = s.substring("", ".").lengthfor (i in 0 until a) {m += stringToInt(s.substring(i, i + 1)) * aa(a - i)}if (s.substring(".", "km").length == 1) {m += stringToInt(s.substring(".", "km")) * 100}}return m}private fun aa(a: Int): Int {if (a == 1)return 1000if (a == 2)return 10000if (a == 3)return 100000if (a == 4)return 1000000if (a == 5)return 10000000return 0}private fun stringToInt(s: String): Int {if (s == "0") {return 0}if (s == "1") {return 1}if (s == "2") {return 2}if (s == "3") {return 3}if (s == "4") {return 4}if (s == "5") {return 5}if (s == "6") {return 6}if (s == "7") {return 7}if (s == "8") {return 8}if (s == "9") {return 9}return -1}// 优化版// 修复了前后传入字符相同时会Overfun String.substring(startStr: String = "", endStr: String = ""): String {val start = if (startStr.isEmpty()) {0} else {this.indexOf(startStr) + startStr.length}val str = this.substring(start)val end = if (endStr.isEmpty()) {str.length} else {str.indexOf(endStr)}return str.substring(0, end)}private fun tap(x: Int, y: Int) {val builder = GestureDescription.Builder()val p = Path()p.moveTo(x.toFloat(), y.toFloat())builder.addStroke(StrokeDescription(p, 0L, 500L))val gesture = builder.build()dispatchGesture(gesture, object : GestureResultCallback() {override fun onCompleted(gestureDescription: GestureDescription) {super.onCompleted(gestureDescription)}override fun onCancelled(gestureDescription: GestureDescription) {super.onCancelled(gestureDescription)}}, null)}private fun swipe(xStart: Int,yStart: Int,xEnd: Int,yEnd: Int,startTime: Long,duration: Long) {val builder = GestureDescription.Builder()val p = Path()p.moveTo(xStart.toFloat(), yStart.toFloat())p.lineTo(xEnd.toFloat(), yEnd.toFloat())builder.addStroke(StrokeDescription(p, startTime, duration))val gesture = builder.build()dispatchGesture(gesture, object : GestureResultCallback() {override fun onCompleted(gestureDescription: GestureDescription) {super.onCompleted(gestureDescription)}override fun onCancelled(gestureDescription: GestureDescription) {super.onCancelled(gestureDescription)}}, null)}override fun onInterrupt() {}
}

这篇关于首汽约车自动抢单功能和源代码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/316391

相关文章

SWAP作物生长模型安装教程、数据制备、敏感性分析、气候变化影响、R模型敏感性分析与贝叶斯优化、Fortran源代码分析、气候数据降尺度与变化影响分析

查看原文>>>全流程SWAP农业模型数据制备、敏感性分析及气候变化影响实践技术应用 SWAP模型是由荷兰瓦赫宁根大学开发的先进农作物模型,它综合考虑了土壤-水分-大气以及植被间的相互作用;是一种描述作物生长过程的一种机理性作物生长模型。它不但运用Richard方程,使其能够精确的模拟土壤中水分的运动,而且耦合了WOFOST作物模型使作物的生长描述更为科学。 本文让更多的科研人员和农业工作者

基于51单片机的自动转向修复系统的设计与实现

文章目录 前言资料获取设计介绍功能介绍设计清单具体实现截图参考文献设计获取 前言 💗博主介绍:✌全网粉丝10W+,CSDN特邀作者、博客专家、CSDN新星计划导师,一名热衷于单片机技术探索与分享的博主、专注于 精通51/STM32/MSP430/AVR等单片机设计 主要对象是咱们电子相关专业的大学生,希望您们都共创辉煌!✌💗 👇🏻 精彩专栏 推荐订阅👇🏻 单片机

Python3 BeautifulSoup爬虫 POJ自动提交

POJ 提交代码采用Base64加密方式 import http.cookiejarimport loggingimport urllib.parseimport urllib.requestimport base64from bs4 import BeautifulSoupfrom submitcode import SubmitCodeclass SubmitPoj():de

Shell脚本实现自动登录服务器

1.登录脚本 login_server.sh #!/bin/bash# ReferenceLink:https://yq.aliyun.com/articles/516347#show all host infos of serverList.txtif [[ -f ./serverList.txt ]]thenhostNum=`cat ./serverList.txt | wc -l`e

Jenkins 通过 Version Number Plugin 自动生成和管理构建的版本号

步骤 1:安装 Version Number Plugin 登录 Jenkins 的管理界面。进入 “Manage Jenkins” -> “Manage Plugins”。在 “Available” 选项卡中搜索 “Version Number Plugin”。选中并安装插件,完成后可能需要重启 Jenkins。 步骤 2:配置版本号生成 打开项目配置页面。在下方找到 “Build Env

以后写代码都是AI自动写了,Cursor+Claude-3.5-Sonnet,Karpathy 点赞的 AI 代码神器。如何使用详细教程

Cursor 情况简介 AI 大神 Andrej Karpathy 都被震惊了!他最近在试用 VS Code Cursor +Claude Sonnet 3.5,结果发现这玩意儿比 GitHub Copilot 还好用! Cursor 在短短时间内迅速成为程序员群体的顶流神器,其背后的原因在于其默认使用 OpenAI 投资的 Claude-3.5-Sonnet 模型,这一举动不仅改变了代码生成

运营版开源代码 多语言跨境商城 跨境电商平台

默认中英双语 后台带翻译接口 支持133种语言自动翻译 支持多商户联盟 一键部署版本 伪静态+后台登陆后缀 源码下载:https://download.csdn.net/download/m0_66047725/89722389 更多资源下载:关注我。

在 Qt Creator 中,输入 /** 并按下Enter可以自动生成 Doxygen 风格的注释

在 Qt Creator 中,当你输入 /** 时,确实会自动补全标准的 Doxygen 风格注释。这是因为 Qt Creator 支持 Doxygen 以及类似的文档注释风格,并且提供了代码自动补全功能。 以下是如何在 Qt Creator 中使用和显示这些注释标记的步骤: 1. 自动补全 Doxygen 风格注释 在 Qt Creator 中,你可以这样操作: 在你的代码中,将光标放在

Jenkins自动构建部署项目

1. 楔子 在实际开发中,经常需要编译、静态代码检查、自动化测试、打包、部署、启动等一连串重复机械的动作,浪费时间、而且容易出错,而Jenkins就是专门Continuous integration(CI)/ Continuous Deploy(CD)开源工具,本文简单介绍Jenkins的使用。 在线无安装免费试用Jenkins:http://www.jenkins.org.cn/test

【Spring Boot】 SpringBoot自动装配-Condition

目录 一、前言二、 定义2.1 @Conditional2.2 Condition2.2.1 ConditionContext 三、 使用说明3.1 创建项目3.1.1 导入依赖3.1.2 添加配置信息3.1.3 创建User类3.1.4 创建条件实现类3.1.5 修改启动类 3.2 测试3.2.1 当user.enable=false3.2.2 当user.enable=true 3.3