- 模拟手机点击代码
import subprocess
import time
def loop_click_for_android(run_time=5):
res = subprocess.Popen(‘adb devices’,
shell=True, stdout=subprocess.PIPE)
res.stdout.read()
inputs = str(input("请确保已打开测试页面(y/n): "))
if inputs == "y":
num = 0
node_time = time.time()
start_buttun = subprocess.Popen("adb shell input tap 160 1400 ")
print("发送点击次数{}".format(num)) # 次数统计并不准确
else:
print("程序关闭~")
exit(1)
loop_click_for_android()
- 模拟手机滑动代码
from os import system
def one(dx, dy):
system(“adb shell input swipe 1700 950 %d %d” % (1700 + dx, 950 + dy))
system(“adb shell input swipe 1810 760 %d %d” % (1810 + dx, 760 + dy))
def move(dx, dy, ms):
system(“adb shell input swipe 340 845 %d %d %d” % (340 + dx, 845 + dy, ms))
while True:
one(120, -450)
move(-125, 125, 3000)
one(120, -450)
move(100, -100, 3000)
one(120, -450)
move(100, 100, 3000)