Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

capture android device screenshot with adb & perl [duplicate]

I tried the one liner solution to capture screenshot via adb and the file is created successfully on PC but it is unreadable:

 C:\Program Files\Android\android-sdk\platform-tools>adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > c:\users\utilisateur\desktop\android_screenshot1.png

enter image description here

The file seem to be correct but I think the Magic is not correct: enter image description here

EDIT: The same issue happened with Git Bash for Windows.

like image 660
M. A. Avatar asked Apr 11 '15 02:04

M. A.


People also ask

How do you capture a screenshot on Android?

Press the Power and Volume down buttons at the same time. If that doesn't work, press and hold the Power button for a few seconds. Then tap Screenshot. If neither of these work, go to your phone manufacturer's support site for help.

How to get screenshot data from Android phone using adb?

In this example, we will use subprocess.Popen () to run adb command and get the data of android phone screenshot. Then we will save image data to png file. You should notice: binary_screenshot cotains the screenshot data, the type of it is byte.

How to take a screenshot on Android without root?

Android Screen Capture Using ADB. Objective: Take a screenshot of an Android device display using adb shell. To take a screenshot of an Android device display, we will need to use the screencap utility. This does not require root access. Screenshots are saved in PNG format. Connect your Android device to the computer with a USB cable.

How do I screen record with ADB shell script?

adb shell screenrecord /sdcard/example.mp4. This command will start recording your device’s screen using the default settings and save the resulting video to a file at /sdcard/example.mp4 file on your device. When you’re done recording, press Ctrl+C in the Command Prompt window to stop the screen recording.

How do I delete a screenshot from my Android device?

To pull the file from your Android device to your computer, use the adb pull command. Once the file has been transferred to your computer, you can delete the file from your Android device. If you would like the screenshot file to be written directly to your computer, then we can tell screencap to write the output to stdout instead.


1 Answers

adb exec-out screencap -p > screen.png

will save it on your machine directly

like image 150
Pablo Acevedo Noda Avatar answered Sep 29 '22 20:09

Pablo Acevedo Noda