Thursday, June 28, 2012

Take screenshots at an interval with powershell

The following script allows you take screenshots of your desktop at the interval you specify.

Make sure you enable the unrestricted execution policy before running the script.

set-executionpolicy unrestricted

[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, 1440, 900)




$i=1
while(1){
$i=$i+1


sleep -sec 6;  screenshot $bounds "c:\images\image$i.png";
}


Requirements:

  • Powershell
  • change folder in script to where you want it saved
  • change resolution of images to size you want
  • Specify the interval in seconds


Download:

No comments:

Post a Comment