powershell - 如何在 Windows PowerShell 中进行屏幕捕获?

标签 powershell

如何在 Windows PowerShell 中捕获屏幕?我需要能够将屏幕保存到磁盘。

最佳答案

您还可以使用 .NET 以编程方式截取屏幕截图(这使您可以更好地控制):

[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"

关于powershell - 如何在 Windows PowerShell 中进行屏幕捕获?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2969321/

相关文章:

powershell - Powershell-Http请求的超时

ruby-on-rails - LearnRubyTheHardWay Ex#46 - rake 中止,你应该需要 'minitest/autorun'

arrays - 测试连接$ False不会转换为ArrayList

powershell - 批量增量文件重命名

asp.net - 如何使用Powershell在Windows Server 2012 IIS网站上启用Windows身份验证?

powershell - 使用get-childitem时,Powershell Remove-Item项目为Null

powershell - 没有参数时如何在powershell中显示Get-Help

powershell - 将变量传递给 register-objectevent 操作 block

xml - 如何在powershell中获取深度深度xml值

powershell - 如何通过输入包含文件路径的变量在 powershell 中打开文件?