Python-adb模拟手机上划操作

时间:2020-10-30 11:57:47   收藏:0   阅读:30
import time
import subprocess

sleep_time = 10

while 1:
    # 用popen设置shell=True不会弹出cmd框
    process = subprocess.Popen(adb shell input touchscreen swipe 930 880 930 380, shell=True)
    time.sleep(sleep_time)
 

 

adb shell input touchscreen swipe 930 880 930 380 //向上滑
adb shell input touchscreen swipe 930 880 330 880 //向左滑
adb shell input touchscreen swipe 330 880 930 880 //向右滑
adb shell input touchscreen swipe 930 380 930 880 //向下滑
adb shell input mouse tap 100 500

100是x,500是y。
原点在屏幕左上角。

 

 在adb文件夹下建立一个python文件

import os
os.system(adb shell input tap 100 100);

 

运行脚本,发现与在命令行输入相同语句有同样的效果。

2、也可以使用subprocess.Popen,最简单使用方式如下,设置shell=True,就不会弹出cmd框

process = subprocess.Popen(‘adb shell input touchscreen swipe 930 880 930 380‘, shell=True)
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!