如何在 Windows PowerShell 中进行屏幕捕获? [英] How can I do a screen capture in Windows PowerShell?
本文介绍了如何在 Windows PowerShell 中进行屏幕捕获?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 Windows PowerShell 中捕获屏幕?我需要能够将屏幕保存到磁盘.
How can I capture the screen in Windows PowerShell? I need to be able to save the screen to disk.
推荐答案
您还可以使用 .NET 以编程方式截取屏幕截图(这让您可以更好地控制):
You can also use .NET to take the screenshot programatically (which gives you finer control):
[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, 1000, 900)
screenshot $bounds "C:\screenshot.png"
这篇关于如何在 Windows PowerShell 中进行屏幕捕获?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文