Skip to content

Instantly share code, notes, and snippets.

@quantumcore
Created February 25, 2020 15:33
Show Gist options
  • Save quantumcore/bfad441f207a2183401f79c6798b9305 to your computer and use it in GitHub Desktop.
Save quantumcore/bfad441f207a2183401f79c6798b9305 to your computer and use it in GitHub Desktop.
Powershell to take screenshot.
[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, 1600, 900)
screenshot $bounds "out.png"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment