Pyhton使用adb直接获取安卓手机screenshot,不保存成文件

xiaoxiao2021-02-28  32

安卓开发配置教程

请参考:https://github.com/wangshub/wechat_jump_game/wiki/Android-和-iOS-操作步骤

使用Python调用adb相关

获取手机屏幕

process = subprocess.Popen('adb shell screencap -p', shell=True, stdout=subprocess.PIPE) screenshot = process.stdout.read() binary_screenshot = screenshot.replace(b'\r\n', b'\n') img = cv2.imdecode(np.frombuffer(binary_screenshot, np.uint8), cv2.IMREAD_COLOR)

模拟按压

cmd = 'adb shell input swipe {x1} {y1} {x2} {y2} {duration}'.format( x1=swipe_x1, y1=swipe_y1, x2=swipe_x2, y2=swipe_y2, duration=press_time ) os.system(cmd)
转载请注明原文地址: https://www.6miu.com/read-2629114.html

最新回复(0)