Skip to content

Instantly share code, notes, and snippets.

@fellypsantos
Created September 29, 2022 12:45
Show Gist options
  • Save fellypsantos/c0bd3108e3f1ce2e4e87745f2a4eb445 to your computer and use it in GitHub Desktop.
Save fellypsantos/c0bd3108e3f1ce2e4e87745f2a4eb445 to your computer and use it in GitHub Desktop.
Take a screenshot from phone connected over adb, and save it to desktop.
@echo off
REM Screenshots will be saved to save directory
REM where your script is running.
REM Generate filename as timestamp
set FILENAME=%DATE:/=-%@%TIME::=-%
set FILENAME=%FILENAME: =%
set FILENAME=%FILENAME:,=.%.png
REM Capture a screenshot and save to /sdcard/screen.png on your Android device.
adb shell screencap -p /sdcard/screen.png
REM Grab the screenshot from /sdcard/screen.png to /tmp/screen.png on your PC.
adb pull /sdcard/screen.png ./%FILENAME%
REM Delete /sdcard/screen.png
adb shell rm /sdcard/screen.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment