截取屏幕截图时保存多个文件

时间:2017-09-29 05:57:12

标签: powershell screenshot

$n = 0
timeout 5
while ($n -le 10) {
   [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, 3840, 2160)
  screenshot $bounds "C:\screenshot.png"

  [System.Windows.Forms.SendKeys]::SendWait("{right}") 

  $n = $n + 1
}

所以我试图截取屏幕截图,向右移动然后再截取9次屏幕截图。但是,所有屏幕截图都会保存到一个文件“screenshot.png”中。如何修复此问题并保存到多个文件中?

0 个答案:

没有答案