Created
January 5, 2016 12:08
-
-
Save Nilzor/78e9e4a4cd14268a7fe2 to your computer and use it in GitHub Desktop.
Android screenshot and video grab helper script for PowerShell
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
<# | |
.SYNOPSIS | |
Records a video to a temp file on the device then downloads to local system and deletes temp file. | |
.PARAMETER DestFile | |
Destination path and file on local file system | |
.NOTES | |
Author : Frode Nilsen <[email protected]> | |
.EXAMPLE | |
And-Record c:\temp\video.mp4 | |
.LINK #> | |
function global:And-Record() { | |
Param( | |
[Parameter(Position=1,Mandatory=$TRUE)] | |
[String] $DestFile | |
) | |
$FileName = [System.IO.Path]::GetFileName($DestFile) | |
Write-Host "Recording video to $FileName. Ctrl+C when done" | |
if ($FileName -eq "") { Write-Error "'DestFile' must include a file name" } | |
else { | |
$TempDeviceFile = "/sdcard/temp-video.mp4" | |
Start-Process -Wait "adb" -ArgumentList "shell screenrecord $TempDeviceFile" | |
adb pull $TempDeviceFile $DestFile | |
adb shell rm $TempDeviceFile | |
} | |
} |
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
<# | |
.SYNOPSIS | |
Grabs a screenshot and optionally resizes it to a scale of choice. | |
.DESCRIPTION | |
Resizing depends on Imagemagick being installed. | |
.PARAMETER DestFile | |
Destination path and file on local file system | |
.PARAMETER ResizePercent | |
Scale in percentage. If not provided will not rescale | |
.NOTES | |
Author : Frode Nilsen <[email protected]> | |
.EXAMPLE | |
And-Screenshot c:\temp\screenshot.png | |
.LINK | |
http://www.imagemagick.org/script/binary-releases.php#windows | |
#> | |
function global:And-Screenshot() { | |
Param( | |
[Parameter(Position=1,Mandatory=$TRUE)] | |
[String] $DestFile, | |
[Parameter(Position=2, Mandatory=$FALSE)] | |
[int] $ResizePercent | |
) | |
if ($ResizePercent -eq "") { $ResizePercent = "33" } | |
$FileName = [System.IO.Path]::GetFileName($DestFile) | |
if ($FileName -eq "") { Write-Error "'DestFile' must include a file name" } | |
else { | |
$ResizePercentStr = "$ResizePercent%" | |
$OutStr = "Screngrabbing to $DestFile" | |
if ($ResizePercent -ne "100") { | |
$OutStr += " and resizing to $ResizePercentStr of original size" | |
} | |
Write-Host $OutStr | |
$TempDeviceFile = "/sdcard/temp-screen.png" | |
adb shell screencap -p $TempDeviceFile | |
adb pull $TempDeviceFile $DestFile | |
adb shell rm $TempDeviceFile | |
if ($ResizePercent -ne "100") { | |
convert $DestFile -resize $ResizePercentStr $DestFile | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment