Created
July 1, 2021 23:36
-
-
Save farukyildiz/e5d2b1764235f53a9240d46aa532ea13 to your computer and use it in GitHub Desktop.
Powershell screenshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("$env:USERPROFILE\test.png") | |
$graphics.Dispose() | |
$bmp.Dispose() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment