title: Python inactive screen capture
body: <p>I want to make a screenshot of an inactive window with win32gui.</p>
  
  <pre><code>from PIL import ImageGrab
  import win32gui
  
  hwnd = win32gui.FindWindow(None, 'Calculator')
  win32gui.SetForegroundWindow(hwnd)
  dimensions = win32gui.GetWindowRect(hwnd)
  
  image = ImageGrab.grab(dimensions)
  image.show()
  </code></pre>
  
  <p>But it is not working as expected. It grabs a screen region but it does not grab exactly where the window is.  I have also tried resizing the calculator window but it doesn't help. My screen resolution is 1920*1080 if that is relevant.  </p>
  
  <p>Screenshot:</p>
  
  <p><a href="https://i.stack.imgur.com/skDuD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/skDuD.png" alt="Calculator attempt"></a>. </p>
  
  <p>Please help me if you have any solutions.</p>