Python-adb模拟手机上划操作

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)
原文地址:https://www.cnblogs.com/sugh/p/13896471.html