当前位置:   article > 正文

adb 脚本化Android系统截图和录屏_手机截屏脚本

手机截屏脚本

1、首先我们了解截图和录屏最基础的命令

  • 手机录屏
adb shell screenrecord sdcard/Record_xxx.mp4
  • 1
  • 导出手机录屏
adb pull sdcard/Record_xxx.mp4
  • 1
  • 手机截屏
adb shell screencap /sdcard/Screenshots_xxx.png
  • 1
  • 导出手机截屏
adb pull sdcard/Screenshots_xxx.png
  • 1

2、实际开发中我们为了提高工作效率,采用脚本

  • 录屏脚本 screenrecord.bat,root环境下调试使用
  :: ITplus
  :: V 1.0.0
  @echo off
  color 02
  :: 保证手机非锁屏状态,锁屏状态录制不成功文件大小为0kb
  :: 录制10s,可以手动修改
  set recordtime=30
  echo start screenrecord %recordtime% s
  set filename=screenrecord%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
  adb shell screenrecord sdcard/%filename%.mp4 --time-limit %recordtime% --bugreport
  echo copy  screenrecord %filename%.mp4
  adb pull sdcard/%filename%.mp4
  echo remove  screenrecord %filename%.mp4
  adb shell rm sdcard/%filename%.mp4
  echo screenrecord success
  pause
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 对录屏脚本进行升级,支持设置录制时长
:: ITplus
:: V 2.0.0
@echo off
color 02
:: 保证手机非锁屏状态,锁屏状态录制不成功文件大小为0kb
:: 录制10s,可以手动修改
chcp 65001
cls
echo ######################请选择要执行的操作######################
echo *---------------------1、输入录屏时长,以秒为单位-------------*
echo *---------------------最少10s,少于10秒录制不成功-------------*
echo ##############################################################
:reinput
set /p recordtime= 请输入:

if %recordtime% LSS 10 (
echo 最少10秒,少于10秒录制不成功
goto reinput
)

if %recordtime% GTR 600 (
echo 最多录制10分钟
goto reinput
)

chcp 936
cls
echo start screenrecord %recordtime% s
set filename=screenrecord%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
adb shell screenrecord sdcard/%filename%.mp4 --time-limit %recordtime% --bugreport
echo copy  screenrecord %filename%.mp4
adb pull sdcard/%filename%.mp4
echo remove  screenrecord %filename%.mp4
adb shell rm sdcard/%filename%.mp4
echo screenrecord success
pause
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 截图脚本 Screenshots.bat
:: ITplus
:: V 1.0.0
echo off
color 02
set filename=Screenshots%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
echo start screencap
adb shell screencap /sdcard/%filename%.png
echo copy screencap %filename%.png
adb pull /sdcard/%filename%.png
echo remove screencap %filename%.png
adb shell rm /sdcard/%filename%.png
echo screencap success
pause
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 对截图脚本进行升级,支持连续截图
:: ITplus
:: V 2.0.0
echo off
color 02

:again
chcp 936
cls
:: 开始截图
set filename=Screenshots%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
echo start screencap
adb shell screencap /sdcard/%filename%.png
echo copy screencap %filename%.png
adb pull /sdcard/%filename%.png
echo remove screencap %filename%.png
adb shell rm /sdcard/%filename%.png
echo screencap success
:: 完成截图

chcp 65001
cls
echo ######################请选择要执行的操作######################
echo *---------------------1、输入1继续截图-----------------------*
echo *---------------------2、输入其他退出 -----------------------*
echo ##############################################################

set /p a= 请输入:

if "%a%" == "1" (
goto again
)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/967459
推荐阅读
相关标签
  

闽ICP备14008679号