SHARE
TWEET

screenshot

jsmth90 Mar 25th, 2019 (edited) 2,939 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ([Reflection.Assembly]::LoadWithPartialName("System.Drawing")) | Out-Null
  2. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
  3. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
  4. function screenshot($path)
  5. {
  6.     $width = 0;
  7.     $height = 0;
  8.     $workingAreaX = 0;
  9.     $workingAreaY = 0;
  10.     $screen = [System.Windows.Forms.Screen]::AllScreens;
  11.     foreach ($item in $screen)
  12.     {
  13.         if($workingAreaX -gt $item.WorkingArea.X)
  14.         {
  15.             $workingAreaX = $item.WorkingArea.X;
  16.         }
  17.         if($workingAreaY -gt $item.WorkingArea.Y)
  18.         {
  19.             $workingAreaY = $item.WorkingArea.Y;
  20.         }
  21.         $width = $width + $item.Bounds.Width;
  22.         if($item.Bounds.Height -gt $height)
  23.         {
  24.             $height = $item.Bounds.Height;
  25.         }
  26.     }
  27.     $bounds = [Drawing.Rectangle]::FromLTRB($workingAreaX, $workingAreaY, $width, $height);
  28.     $bmp = New-Object Drawing.Bitmap $width, $height;
  29.     $graphics = [Drawing.Graphics]::FromImage($bmp);
  30.     $graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size);
  31.     $bmp.Save($path);
  32.     $graphics.Dispose();
  33.     $bmp.Dispose();
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top