Skip to content

Instantly share code, notes, and snippets.

@mintsoft
Created April 27, 2016 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mintsoft/fe4f591e4788fb84e83d61da884c0762 to your computer and use it in GitHub Desktop.
Save mintsoft/fe4f591e4788fb84e83d61da884c0762 to your computer and use it in GitHub Desktop.
Screenshot.ps1
[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, 1280, 1024)
screenshot $bounds "C:\Atemp\$(get-date -format "yyyy-MM-ddTHH-mm-ss").png"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment