Skip to content

Instantly share code, notes, and snippets.

@and2long
Last active July 26, 2020 05:01
Show Gist options
  • Save and2long/9c4649351a892e16bcac32e6e55272c4 to your computer and use it in GitHub Desktop.
Save and2long/9c4649351a892e16bcac32e6e55272c4 to your computer and use it in GitHub Desktop.
(安卓)自动滑动视频。
import re, os, sys, time, datetime
class AutoScroll(object):
def __init__(self):
self.devices = []
self.count = 0
def find_devices(self):
data = os.popen("adb devices").readlines()
if "List of devices attached\n" in data:
for item in data:
if "\t" in item:
self.devices.append(item.split("\t")[0])
print("检测到{}个设备:\n{}".format(len(self.devices), self.devices))
else:
print("没有检测到任何设备连接。")
def scroll(self):
while True:
self.count += 1
print("{} swipe :{}".format(datetime.datetime.now(), self.count))
for device in self.devices:
os.system("adb -s {} shell input swipe 500 500 500 400 100".
format(device))
time.sleep(10)
def start(self):
self.find_devices()
if len(self.devices) > 0:
print("{} 开始执行自动滑动:".format(datetime.datetime.now()))
self.scroll()
else:
try:
sys.exit()
except:
print("请稍后重试。")
if __name__ == "__main__":
AutoScroll().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment