如题,最近搜索adb截图,网上的方法大都是保存到手机存储,然后再从手机存储复制到PC上。
adb shell screencap /sdcard/1.png
adb pull /sdcard/1.png .
通过查看adb screencap命令的帮助看到:
~/Downloads adb shell screencap -h
usage: screencap [-hp] [-d display-id] [FILENAME]
-h: this message
-p: save the file as a png.
-j: save the file as a jpeg.
-d: specify the display id to capture, default 0.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.
如果不指定文件名,是可以将图片内容输出到stdout中的,因此可以这样直接保存到pc:
adb shell screencap -p > 1.png
经尝试也没有问题,可为什么都没有人这么用呢?
经过测试,
adb shell screencap -p > 1.png
的方式在android 6.0.1版本上无法使用,在7.0及以后系统中正常。6.0版本可以使用
adb exec-out screencap -p > 1.png
。测试手机:MOTO XT1077,CM 13.0,Android 6.0.1。