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

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

  • 手机录屏

    adb shell screenrecord sdcard/Pictures/Screenshots/Record_xxx.mp4

  • 导出手机录屏

    adb pull sdcard/Pictures/Screenshots/Record_xxx.mp4

  • 手机截屏

    adb shell screencap /sdcard/Screenshots_xxx.png

  • 导出手机截屏

    adb pull sdcard/Pictures/Screenshots/Screenshots_xxx.png

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/Pictures/Screenshots/%filename%.mp4 --time-limit %recordtime% --bugreport
    echo copy  screenrecord %filename%.mp4
    adb pull sdcard/Pictures/Screenshots/%filename%.mp4
    echo remove  screenrecord %filename%.mp4
    adb shell rm sdcard/Pictures/Screenshots/%filename%.mp4
    echo screenrecord success
    pause
    
  • 对录屏脚本进行升级,支持设置录制时长

    :: 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/Pictures/Screenshots/%filename%.mp4 --time-limit %recordtime% --bugreport
    echo copy screenrecord %filename%.mp4
    adb pull sdcard/Pictures/Screenshots/%filename%.mp4
    echo remove screenrecord %filename%.mp4
    adb shell rm sdcard/Pictures/Screenshots/%filename%.mp4
    echo screenrecord success
    pause

  • 截图脚本 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

  • 对截图脚本进行升级,支持连续截图

    :: 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
    )

相关推荐
Yawesh_best1 小时前
MySQL(5)【数据类型 —— 字符串类型】
android·mysql·adb
落落落sss6 小时前
MQ集群
java·服务器·开发语言·后端·elasticsearch·adb·ruby
运维佬18 小时前
在 MySQL 8.0 中,SSL 解密失败,在使用 SSL 加密连接时出现了问题
mysql·adb·ssl
qq_308957472 天前
adb 如何通过wifi连接手机
adb·智能手机·app自动化测试
白如意i2 天前
如何在 CentOS 6 上设置 NFS 挂载
数据库·mysql·adb
七月.末2 天前
安卓aab包的安装教程,附带adb环境的配置
android·adb
SRC_BLUE_173 天前
SQLI LABS | Less-39 GET-Stacked Query Injection-Intiger Based
android·网络安全·adb·less
jason.zeng@15022074 天前
ubuntu中安装mysql
mysql·ubuntu·adb
看山还是山,看水还是。4 天前
MySQL 安装
运维·数据库·笔记·学习·mysql·adb
开心呆哥5 天前
【如何使用 Python 脚本通过 ADB 命令来检查 Android 文件内容】
android·python·adb