当前位置: 首页 > news >正文

adb 与pad 交互方法

event

import requests
import time
import random
import os# http://fspcdiy.d33173.chshtzs.com/action.php
# 连接设备(有线直接连接,无线需先执行adb tcpip 5555)
os.system('adb devices')  # 验证连接# 定义点击函数
def tap(x, y):os.system(f'adb shell input tap {x} {y}')def check_status():# 添加随机参数和禁用缓存的请求头timestamp = int(time.time())rand = random.randint(0, 9999)url = f"http://fspcdiy.d33173.chshtzs.com/do.php?cmd=status&_={timestamp}{rand}"headers = {'Cache-Control': 'no-cache, no-store, must-revalidate','Pragma': 'no-cache','Expires': '0'}try:response = requests.get(url, headers=headers)if response.status_code == 200:content = response.text.strip()if content.startswith("Current action: "):value = content[len("Current action: "):].strip()print('test:' + value)return valuereturn Noneexcept requests.RequestException as e:print(f"请求出错: {e}")return Nonedef delete_action():# 同样为delete请求添加防缓存措施timestamp = int(time.time())rand = random.randint(0, 9999)delete_url = f"http://fspcdiy.d33173.chshtzs.com/do.php?cmd=delete&_={timestamp}{rand}"headers = {'Cache-Control': 'no-cache, no-store, must-revalidate','Pragma': 'no-cache','Expires': '0'}try:requests.get(delete_url, headers=headers)except requests.RequestException as e:print(f"删除操作出错: {e}")def main():while True:value = check_status()if value and value != "No action stored":if value == "UP":print("UP")# 向上tap(1719, 510)time.sleep(3)delete_action()elif value == "DOWN":print("DOWN")# 向下tap(1719, 688)time.sleep(3)delete_action()elif value == "LEFT":print("LEFT")# 向左tap(1626, 606)time.sleep(3)delete_action()elif value == "RIGHT":print("RIGHT")# 向右tap(1800, 596)time.sleep(3)delete_action()elif value == "CLAMP":print("CLAMP")# 夹子tap(1000, 1132)time.sleep(3)delete_action()elif value == "FOOD1":print("FOOD1")# 动作1 上tap(285, 521)time.sleep(3)delete_action()elif value == "FOOD2":print("FOOD2")# 动作2 下tap(290, 704)time.sleep(3)delete_action()elif value == "FOOD3":print("FOOD3")# 动作3 左tap(195, 607)time.sleep(3)delete_action()elif value == "FOOD4":print("FOOD4")# 动作4 右tap(377, 608)time.sleep(3)delete_action()else:print(f"未知动作: {value}")time.sleep(3)if __name__ == "__main__":main()

do.php

<?php
// 定义存储文件路径
$storage_file = 'shared_action.txt';if (isset($_GET['action'])) {file_put_contents($storage_file, $_GET['action']);echo "Action stored: " . htmlspecialchars($_GET['action']);
} elseif (isset($_GET['cmd'])) {$command = strtolower($_GET['cmd']);if ($command === 'status') {if (file_exists($storage_file)) {echo "Current action: " . htmlspecialchars(file_get_contents($storage_file));} else {echo "No action stored";}} elseif ($command === 'delete') {if (file_exists($storage_file)) {unlink($storage_file);}echo "Action deleted successfully";} else {echo "Invalid command";}
} else {// 显示使用说明echo "<h1>Action Management System</h1>";// ... 其余HTML代码 ...
}
?>
http://www.dtcms.com/a/312567.html

相关文章:

  • PPT自动化 python-pptx - 9: 图表(chart)
  • 服务器中切换盘的操作指南
  • Jetson Orin NX/NANO+ubuntu22.04+humble+MAVROS2安装教程
  • Kafka——常见工具脚本大汇总
  • /usr/bin/ld: 找不到 -lev
  • stm32f103重新上电后前面的打印内容无法打印出来的原因
  • Springboot 04 starter
  • 分布式文件系统05-生产级中间件的Java网络通信技术深度优化
  • ClickHouse Windows迁移方案与测试
  • HiveMQ 2024.9 设计与开发文档
  • 知识随记-----MySQL 连接池健康检测与 RAII 资源管理技术
  • Timer串口常用库函数(STC8系列)
  • Docker--解决x509: certificate signed by unknown authority
  • 系统学习算法:专题十六 字符串
  • 基于SpringBoot+MyBatis+MySQL+VUE实现的电商平台管理系统(附源码+数据库+毕业论文+部署教程+配套软件)
  • WSUS服务器数据库维护与性能优化技术白皮书
  • Leetcode 12 java
  • CSS 预处理器(Preprocessor)和后处理器(Postprocessor)
  • python工具方法51 视频数据的扩充(翻转、resize、crop、re_fps)
  • 01.MySQL 安装
  • 仓库管理系统-15-前端之管理员管理和用户管理
  • 01数据结构-时间复杂度和空间复杂度
  • 每日五个pyecharts可视化图表-bars(2)
  • HCIP笔记(第四章)
  • Flutter各大主流状态管理框架技术选型分析及具体使用步骤
  • 网络原理 - TCP/IP
  • 计算机网络(TCP篇)
  • PPT自动化 python-pptx - 10 : 表格(tables)
  • 力扣经典算法篇-42-矩阵置零(辅助数组标记法,使用两个标记变量)
  • 使命召唤21:黑色行动6 免安 离线 中文版