$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”中。如何修复此问题并保存到多个文件中?