如何在Windows PowerShell中捕获屏幕?我需要能够将屏幕保存到磁盘。
您也可以使用.NET以截图进行截图(这样可以更精细的控制):
原文链接:https://www.f2er.com/windows/373127.html[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,1000,900) screenshot $bounds "C:\screenshot.png"