✅作者简介：热爱科研的算法开发者，Python、Matlab项目可交流、沟通、学习。

🍎个人主页：算法工程师的学习日志

`- 模拟点击事件adb shell input tap x坐标 y坐标adb shell input tap 528 1539- 输入文本首先需要把光标移到输入框，然后执行以下命令adb shell input text zengzengzeng- 模拟滑动事件adb shell swip <起点x> <起点y> <终点x> <终点y> <滑动时长>adb shell input swipe 528 1539 528 1300 20002000为滑动时间，单位是毫秒- 返回键adb shell input keyevent 4- 返回home键（置应用于后台）adb shell input keyevent 3- 音量放大adb shell input keyevent 24- 音量缩小adb shell input keyevent 25`

`adb shell input touchscreen swipe x1 y1 x2 y2touchscreen – 触摸屏幕，swipe – 滑动、滑屏操作x1 y1 x2 y2 – 滑动起始和终止位置的横纵轴坐标，举例如下：adb shell input touchscreen swipe 450 66 110 66`

2、python代码实现

`import timeimport osimport randomdef rand(x0, x1):  # 在x0 x1范围内生成随机两位小数    a = random.uniform(x0, x1)    return round(a, 2)def randint(x0, x1):  # 在x0 x1范围内生成随机整数    return random.randint(x0, x1)# 屏幕向上滑动，随机防封def swipeUp(screensize):    adb_path = os.path.join('Tools', "adb", 'adb.exe')    cmd = '{adb} shell input touchscreen swipe {x1} {y1} {x1} {y2}'.format(        adb=adb_path,        x1=int(int(screensize[0]) * rand(0.4, 0.5)),  # x坐标        y1=int(int(screensize[1]) * rand(0.4, 0.5)),  # 起始y坐标        y2=int(int(screensize[1]) * rand(0.7, 0.8))  # 终点y坐标    )    print(cmd)    os.system(cmd)def short_video():  # 无限循环看视频    adb_path = os.path.join('Tools', "adb", 'adb.exe')    screensize = os.popen(adb_path + ' shell wm size')    output = screensize.read()    screensize = output.replace('\n', '')    screensize = screensize.split(' ')[2]    screensize = screensize.split('x')    print("屏幕宽度 %s" % screensize[0])    print("屏幕高度 %s" % screensize[1])    print("进入循环操作...")    while True:        t4 = randint(1, 6)  # 随机看视频时间，防封        print('等待' + str(t4) + '秒进入下一个视频')        time.sleep(t4)        swipeUp(screensize)short_video()`