adb学习笔记

adb学习笔记

# -*- coding: utf-8 -*-
import subprocess
import time

# 定义一个函数来执行ADB命令
def execute_adb_command(command):
    exe_path = r'D:\java\android_devtools\sdk\platform-tools\adb.exe'
    result = subprocess.run([exe_path] + command.split(), capture_output=True, text=True)
    if result.returncode == 0:
        return result.stdout.strip()
    else:
        raise Exception(f"ADB command failed: {result.stderr}")

if __name__ == '__main__':
    # 示例:获取连接的设备列表
    x = 975
    y = 1245 
    for i in range(6000):
        print(i)
        execute_adb_command(f"shell input tap {x} {y}")
        time.sleep(0.2)

    devices = execute_adb_command("devices")
    print("Connected devices:")
    print(devices)
    pass

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注