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)