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)


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM