Created
January 10, 2017 01:27
-
-
Save Sh1n0g1/428dfa2db501285e286b09ff18a34312 to your computer and use it in GitHub Desktop.
Take a screenshot by 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
[Reflection.Assembly]::LoadWithPartialName("System.Drawing") | |
function screenshot([Drawing.Rectangle]$bounds, $path) { | |
$bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height | |
$graphics = [Drawing.Graphics]::FromImage($bmp) | |
$graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size) | |
$bmp.Save($path) | |
$graphics.Dispose() | |
$bmp.Dispose() | |
} | |
$bounds = [Drawing.Rectangle]::FromLTRB(0, 0, 1000, 900) | |
screenshot $bounds $env:TEMP"\shot.png" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment