metalx1000

Screen Capture on Windows screenshot powershell

Jan 13th, 2017
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [Reflection.Assembly]::LoadWithPartialName("System.Drawing")
  2. function screenshot([Drawing.Rectangle]$bounds, $path) {
  3.    $bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height
  4.    $graphics = [Drawing.Graphics]::FromImage($bmp)
  5.  
  6.    $graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)
  7.  
  8.    $bmp.Save($path)
  9.  
  10.    $graphics.Dispose()
  11.    $bmp.Dispose()
  12. }
  13.  
  14. $bounds = [Drawing.Rectangle]::FromLTRB(0, 0, 1000, 900)
  15. screenshot $bounds "C:\screenshot.png"
Add Comment
Please, Sign In to add comment