查看帮助命令

bixiaopeng@bixiaopeng ~$ adb shell screencap -v
screencap: invalid option -- v
usage: screencap [-hp] [-d display-id] [FILENAME]
   -h: this message
   -p: save the file as a png.
   -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.

注意:

如果文件名以.png结尾时,它将保存为png文件

如果文件名没有给出,则结果被会被输出到stdout

截图保存到SD卡里再导出

$ adb shell screencap -p /sdcard/screen.png
$ adb pull /sdcard/screen.png
$ adb shell rm /sdcard/screen.png

这种方法比较麻烦,需要3步:1. 截图保存到sdcard 2.将图片导出 3.删除sdcard中的图片

截图直接保存到电脑

$ adb shell screencap -p | sed 's/\r$//' > screen.png

执行adb shell 将\n转换\r\n, 因此需要用sed删除多余的\r

如果直接当命令用还可以用 alias 包裝装起來:

$ alias and-screencap="adb shell screencap -p | sed 's/\r$//'"
$ and-screencap > screen.png 

以后就可以方便的用and-screencap > 直接将截图保存到电脑上了

相关文章:

  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-01-31
  • 2021-08-15
  • 2021-10-30
  • 2021-06-29
猜你喜欢
  • 2022-02-06
  • 2021-09-07
  • 2021-12-29
  • 2022-12-23
  • 2021-05-21
  • 2021-08-20
  • 2022-01-26
相关资源
相似解决方案