1. 手动截屏,通过其他第三方软件发送截图,或者从手机取出截图
2. 使用命令截图,将截图保存到手机,再拉取到电脑
#!/bin/sh
#运行 sh screenshot name
picName=$1
filePath='caps'
if [ ! $picName ];then
picName=`date +"%F_%H%M%S"`
fi
if [ ! -d ${filePath} ];then
mkdir ${filePath}
fi
for i in `adb devices|grep -w 'device'|awk '{print $1}'`;do
adb -s $i shell /system/bin/screencap -p /sdcard/$i-${picName}.png
adb -s $i pull /sdcard/$i-${picName}.png ${filePath}
adb -s $i shell rm -rf /sdcard/$i-${picName}.png
done
3. 直接保存到手机
adb shell screencap -p | sed 's/\r$//' > screen.png
Mac执行提示
sed: RE error: illegal byte sequence
参考别人的博客 但截屏不全。
adb shell /system/bin/screencap -p |LC_CTYPE=C sed 's/\r$//' > screen.png
4.录屏
videotime=$1
filename=$2
filePath='caps'
if [ ! -z $2 ];then
filename=$2
else
filename=`date +"%F_%H%M%S"`
fi
if [ ! -z ${videotime} ];then
adb shell screenrecord --time-limit ${videotime} /sdcard/${filename}.mp4
else
adb shell screenrecord /sdcard/${filename}.mp4
fi
adb pull /sdcard/${filename}.mp4 ${filePath}
adb shell <<EOF
cd /sdcard
rm -rf ${filename}.mp4
exit
问题:
1.登陆页面截屏失败
原因:应用出于安全性考虑,会禁止在包含密码的页面进行截屏操作。