Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化截图获取方式 #288

Merged
merged 1 commit into from
Dec 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions wechat_jump_auto.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# coding: utf-8
import os
import sys
import subprocess
import shutil
import time
import math
Expand Down Expand Up @@ -74,12 +75,11 @@ def _get_screen_size():


def pull_screenshot():
flag = os.system('adb shell screencap -p /sdcard/autojump.png')
if flag == 1:
print('请安装ADB并配置环境变量')
sys.exit()
os.system('adb pull /sdcard/autojump.png .')

process = subprocess.Popen('adb shell screencap -p', shell=True, stdout=subprocess.PIPE)
screenshot = process.stdout.read().replace(b'\r\n', b'\n')
f = open('autojump.png', 'wb')
f.write(screenshot)
f.close()

def backup_screenshot(ts):
# 为了方便失败的时候 debug
Expand Down Expand Up @@ -204,9 +204,15 @@ def dump_device_info():
dpi=density_str.strip()
))

def check_adb():
flag = os.system('adb devices')
if flag == 1:
print('请安装ADB并配置环境变量')
sys.exit()

def main():
dump_device_info()
check_adb()
while True:
pull_screenshot()
im = Image.open('./autojump.png')
Expand Down