public Bitmap CaptureWindow(IntPtr handle)
 {
     var hdcSrc = User32.GetWindowDC(handle);
     var windowRect = new User32.RECT();
     User32.GetWindowRect(handle, ref windowRect);
     var width = windowRect.right - windowRect.left;
     var height = windowRect.bottom - windowRect.top;
     var hdcDest = GDI32.CreateCompatibleDC(hdcSrc);
     var hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc, width, height);
     var hOld = GDI32.SelectObject(hdcDest, hBitmap);
     GDI32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, GDI32.SRCCOPY);
     GDI32.SelectObject(hdcDest, hOld);
     GDI32.DeleteDC(hdcDest);
     User32.ReleaseDC(handle, hdcSrc);
     var img = Image.FromHbitmap(hBitmap);
     GDI32.DeleteObject(hBitmap);
     return img;
 }
 public Point GetWindowLUPoint(IntPtr handle)
 {
     var rect = new User32.RECT();
     User32.GetWindowRect(handle, ref rect);
     return new Point(rect.left, rect.top);
 }