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