python 调用adb截图

    p0 = subprocess.Popen("adb shell screencap -p /sdcard/screen2.png",shell= True,
                         stdout = subprocess.PIPE,
                         stderr = subprocess.PIPE,
                         stdin = subprocess.PIPE)
    import time
    time.sleep(0.2)
    p1 = subprocess.Popen("adb pull /sdcard/screen2.png",shell= True,
                         stdout = subprocess.PIPE,
                         stderr = subprocess.PIPE,
                         stdin = subprocess.PIPE)
    print(p1.stdout.readlines()[0].decode())
    p2 = subprocess.Popen("adb shell rm -rf /sdcard/screen2.png",shell= True,
                         stdout = subprocess.PIPE,
                         stderr = subprocess.PIPE,
                         stdin = subprocess.PIPE)

  

posted @ 2024-02-29 21:21  假面之风  阅读(90)  评论(0)    收藏  举报