def screen(self):
        """PIL Image of current window screen.
        reference: https://msdn.microsoft.com/en-us/library/dd183402(v=vs.85).aspx"""
        hwnd = win32gui.GetDesktopWindow()
        left, top, right, bottom = self.rect
        width, height = right-left, bottom-top
        # copy bits to temporary dc
        win32gui.BitBlt(self._hdcmem, 0, 0, width, height, 
                        self._hdcwin, left, top, win32con.SRCCOPY)
        # read bits into buffer
        windll.gdi32.GetDIBits(self._hdcmem, self._hbmp.handle, 0, height, self._buf, ctypes.byref(self._bi), win32con.DIB_RGB_COLORS)
        # make a PIL Image
        img = Image.frombuffer('RGB', (width, height), self._buf, 'raw', 'BGRX', 0, 1)
        img = img.transpose(Image.FLIP_TOP_BOTTOM)
        return img
def screen ( self ) : hwnd = win32gui . GetDesktopWindow ( ) left , top , right , bottom = self . rect width , height = right - left , bottom - top win32gui . BitBlt ( self . _hdcmem , 0 , 0 , width , height , self . _hdcwin , left , top , win32con . SRCCOPY ) windll . gdi32 . GetDIBits ( self . _hdcmem , self . _hbmp . handle , 0 , height , self . _buf , ctypes . byref ( self . _bi ) , win32con . DIB_RGB_COLORS ) img = Image . frombuffer ( 'RGB' , ( width , height ) , self . _buf , 'raw' , 'BGRX' , 0 , 1 ) img = img . transpose ( Image . FLIP_TOP_BOTTOM ) return img
PIL Image of current window screen.
        reference: https://msdn.microsoft.com/en-us/library/dd183402(v=vs.85).aspx