ADB加python操作手机

一、配置adb

网上解压的adb三个包,一定要安装在python所在的目录,一般是sys.path 所显示的第二个路径。

手工添加adb_usb.ini,其中写入从设备管理器中查到的手机序列号。

二、监听手机操作

adb shell

getevent

记录0003 0035、0003 0036两行,并从16进制转为10进制

 

三、操作手机

点击操作

adb shell input tap x y #x,y 为转为10进制后的鼠标坐标

输入文字

adb shell input text xxxxxxx 

 

具体应用代码:

 

import os
import time

ygh_dict = {"3xxxxxxxx":"xxxxxxx",
            "3xxxxxxxx":"xxxxxxxxxx"}

def browse():
    for i in range(1, 200):
        os.system("adb shell input tap 602 2158")
        time.sleep(2)

        os.system("adb shell input tap 488 1467")
        time.sleep(2)

        os.system("adb shell input tap 215 1874")
        time.sleep(3)

        os.system("adb shell input tap 215 1874")
        time.sleep(2)

        os.system("adb shell input tap 71 138")
        time.sleep(1)
        print(i)

        i = i + 1

def clear():
    for j in range(1, 11):
        os.system("adb shell input tap 1000 1982")
        j = j +1

for k, v in ygh_dict.items():
    print(k, v)
    
    os.system("adb shell input tap 602 2158")
    time.sleep(2)


    os.system("adb shell input tap 660 1012")
    time.sleep(2)
    
    clear()
    time.sleep(2)

    os.system("adb shell input text {}".format(k))
    print(k)
    time.sleep(2)

    os.system("adb shell input tap 660 1127")
    time.sleep(2)
    
    clear()
    time.sleep(2)

    os.system("adb shell input text {}".format(v))
    print(v)
    time.sleep(2)

    os.system("adb shell input tap 488 1400")
    time.sleep(2)

    os.system("adb shell input tap 488 1467")
    time.sleep(2)

    os.system("adb shell input tap 215 1874")
    time.sleep(3)

    os.system("adb shell input tap 215 1874")
    time.sleep(2)

    os.system("adb shell input tap 71 138")
    time.sleep(1)

    browse()

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值