Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save betillogalvanfbc/df9333b70bc73e130fb686505e0c4e36 to your computer and use it in GitHub Desktop.
Save betillogalvanfbc/df9333b70bc73e130fb686505e0c4e36 to your computer and use it in GitHub Desktop.
ScreenShotDesktopPowershell.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, 1000, 900)
screenshot $bounds "C:\Temp\sc.png" | Out-Null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment