我试着把我的每一个屏幕截图。
很不幸,我找了几个小时,什么也没找到。
以下是我的PowerShell脚本内容:
Add-Type -AssemblyName System.Windows.Forms,System.Drawing
$screens = [Windows.Forms.Screen]::AllScreens
$top = ($screens.Bounds.Top ^| Measure-Object -Minimum).Minimum
$left = ($screens.Bounds.Left ^| Measure-Object -Minimum).Minimum
$width = ($screens.Bounds.Right ^| Measure-Object -Maximum).Maximum
$height = ($screens.Bounds.Bottom ^| Measure-Object -Maximum).Maximum
$bounds = [Drawing.Rectangle]::FromLTRB($left, $top, $width, $height)
$bmp = New-Object System.Drawing.Bitmap ([int]$bounds.width), ([int]$bounds.height)
$graphics = [Drawing.Graphics]::FromImage($bmp)
$graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)
$bmp.Save("%path%\tmp\Screenshots\%1.png")
$graphics.Dispose()
$bmp.Dispose()
%powershell% -ExecutionPolicy Bypass -File "%path%\librairies\sg.ps1"
这需要我所有屏幕的截图,但在一个文件中,我想检测屏幕的数量,并对每个屏幕进行截图,例如文件名为:Screen1.png
、Screen2.png
等...
1条答案
按热度按时间z6psavjg1#
循环遍历
[Windows.Forms.Screen]::AllScreen
返回的每个屏幕: