Created
December 5, 2013 10:22
-
-
Save leighmcculloch/7803130 to your computer and use it in GitHub Desktop.
This batch script will take a screenshot on an Android device using ADB, download the screenshot to the directory this script to the current directory and then remove the screenshot file from the device. Screenshots are saved with filename: screenshot-YYYYMMDD-HHMMSS.png. ADB must be connected to a device already.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem configurable parameters | |
set SCREENCAP_FILE_PREFIX=screenshot | |
rem the dir on the device where the screenshot will be stored temporarily | |
set SCREENCAP_WORKING_DIR=/sdcard/ | |
rem adb path, leave blank if adb is already on the user or system path | |
set SCREENCAP_ADB_PATH= | |
rem get date and time | |
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set SCREENCAP_DATE=%%c%%a%%b) | |
For /f "tokens=1-4 delims=/:." %%a in ("%TIME%") do (set SCREENCAP_TIME=%%a%%b%%c%%d) | |
rem create output file from parameters and date and time | |
set SCREENCAP_FILE_NAME=%SCREENCAP_FILE_PREFIX%-%SCREENCAP_DATE%-%SCREENCAP_TIME%.png | |
set SCREENCAP_FILE_PATH=%SCREENCAP_WORKING_DIR%%SCREENCAP_FILE_NAME% | |
rem do it! | |
echo Taking Screenshot at %SCREENCAP_DATE%-%SCREENCAP_TIME% | |
echo Output File: %SCREENCAP_FILE_NAME% | |
echo. | |
%SCREENCAP_ADB_PATH%adb shell screencap -p %SCREENCAP_FILE_PATH% | |
%SCREENCAP_ADB_PATH%adb pull %SCREENCAP_FILE_PATH% | |
%SCREENCAP_ADB_PATH%adb shell rm %SCREENCAP_FILE_PATH% | |
echo. | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I have an error :