Last active
July 26, 2020 05:01
-
-
Save and2long/9c4649351a892e16bcac32e6e55272c4 to your computer and use it in GitHub Desktop.
(安卓)自动滑动视频。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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