---
title: "安卓截屏shell脚本"
author: "chenpeilei2003"
date: "2014-08-10T00:26:46Z"
tags: []
categories: ["移动开发"]
slug: "shell"
draft: false
lastmod: "2014-08-10T00:26:46Z"
id: 2102109
url: "https://chenpeilei2003.iteye.com/blog/2102109"
---

写个脚本，不需要每次截屏都在电脑上打开eclipse了

1.写脚本

adb shell /system/bin/screencap -p /sdcard/download/screenshot.png

MM=\`date +%s.png\`

adb pull /sdcard/download/screenshot.png  /Users/BH/Pictures/com.tencent.ScreenCapture/$MM

 

获取shell时间戳并当作文件名，保存到指定目录下，很简单很方便。

2.保存到电脑里（我用的是MAC），保存为screenshot.sh

 

3.设置shell脚本的可执行权限， 用命名 sudo chmod u+x screenshot.sh

 

3.执行shell， 可以在命令行里 /.screenshot.sh   ， 这样就可以成功截屏并保存到电脑里了。