Android截圖命令screencap
查看幫助命令
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 > 直接將截圖保存到電腦上了
技術改變世界!
--狂詩絕劍

浙公網安備 33010602011771號