创建一个bat文件,使用adb截屏,并且把截图文件拉到本地,以时间命名
时间: 2024-11-27 07:16:12 浏览: 36
创建一个批处理脚本来使用ADB(Android Debug Bridge)进行屏幕截图并将截图复制到电脑上,你可以按照以下步骤操作:
1. 首先,确保你的电脑上已经安装了ADB,并将其路径添加到了系统的环境变量中。
2. 在电脑上创建一个新的文本文件,比如命名为`adb_screenshot.bat`。
3. 在这个文件中,输入以下命令行内容:
```batch
@echo off
setlocal enabledelayedexpansion
rem 设置ADB路径,这里假设你的ADB在"C:\Program Files (x86)\Android\Android Studio\platform-tools"
set adb_path=C:\Program Files (x86)\Android\Android Studio\platform-tools\adb.exe
rem 检查ADB是否可用
if not exist "%adb_path%" (
echo ADB路径错误,检查 %adb_path%是否存在。
pause
exit /b 1
)
rem 获取当前时间作为文件名
set filename=screen_%date:~10,4%_%date:~7,2%_%date:~4,2%_%time:~0,2%_%time:~3,2%_%time:~6,2%.png
rem 截图并保存到设备的指定目录,这里假设默认路径为"/sdcard/Screenshots/"
!adb_path! shell screencap -p /sdcard/Screenshots/"!filename!"
rem 将截图从设备同步到本地
!adb_path! pull /sdcard/Screenshots/"!filename!" .
echo 截图已保存为 "!filename!"。
pause
```
请注意替换`adb_path`为你实际的ADB路径。
4. 双击运行此.bat文件,这将会获取当前时间和设备名称,在手机上截图并保存,然后同步到你的电脑的当前目录下。
阅读全文
相关推荐


















