title: VB.NET Window Screen Capture (ALT+PRINTSCREEN)
body: <p>I found that code somewhere and I find it quite useful but I would like to find a way to make it work so it capture only the given window target. Maybe with a processID or Window Name. Even if that window is not active.</p>
  
  <p>I do not want to make that window active but want to get a screen capture like if I was doing Alt+PrintScreen on it.</p>
  
  <p>Here is the code that works for full Screen Capture</p>
  
  <pre><code>    Private bmpScreenShot As Bitmap
      Private gfxScreenshot As Graphics
  
      bmpScreenShot = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb)
  
      gfxScreenshot = Graphics.FromImage(bmpScreenShot)
      gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy)
  
      bmpScreenShot.Save(fileName, ImageFormat.Png)
  </code></pre>
  
  <p>I use the Visual Basic 2008 Express</p>
  
  <p>Thank you in advance!</p>