From ca134e2e235929427d2cdc710dbce823371ebc87 Mon Sep 17 00:00:00 2001 From: Zhuang Ma Date: Fri, 11 Nov 2016 20:11:34 +0800 Subject: [PATCH] Add single line command to screenshot and save to PC --- README.en.md | 8 ++++++++ README.md | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/README.en.md b/README.en.md index fef9aff..999511e 100644 --- a/README.en.md +++ b/README.en.md @@ -1598,6 +1598,14 @@ You can use the `adb shell screencap -h` See` help screencap` command, here are Found If you specify a file name can be omitted when the -p parameter to `.png` ending; otherwise you need to use the -p parameter. If you do not specify a file name, file contents screenshot will be directly output to stdout. +Save screenshot file to computer with a single line command: + +```sh +adb shell screencap -p | sed "s/\r$//" > sc.png +``` + +This depends on `sed` command, it's avaliable in Linux and Mac OS X by default. In Windows, you may find it in bin directory in Git installation place. Otherwise, you may need to download [sed for Windows](http://gnuwin32.sourceforge.net/packages/sed.htm) and add the directory where sed.exe is to PATH environment variable. + ### Recording Screen Record screen are saved in mp4 format to / sdcard: diff --git a/README.md b/README.md index a1851db..6bb63a1 100644 --- a/README.md +++ b/README.md @@ -1598,6 +1598,14 @@ adb pull /sdcard/sc.png 实测如果指定文件名以 `.png` 结尾时可以省略 -p 参数;否则需要使用 -p 参数。如果不指定文件名,截图文件的内容将直接输出到 stdout。 +直接一行命令截图并保存到电脑的方法: + +```sh +adb shell screencap -p | sed "s/\r$//" > sc.png +``` + +这个方法需要用到 sed 命令,在 Linux 和 Mac 下直接就有,在 Windows 下 Git 安装文件夹的 bin 目录下也有。如果确实找不到该命令,可以下载 [sed for Windows](http://gnuwin32.sourceforge.net/packages/sed.htm) 并将 sed.exe 所在目录添加到 PATH 环境变量里。 + ### 录制屏幕 录制屏幕以 mp4 格式保存到 /sdcard: