Maybe this will help. I use it for my darkorbit bot. Though the window has to be visible and not minimized for this to work - just move it offscreen. The screen also has to be turned on.
Code:
public static Bitmap Snapshot(IntPtr handle, Rectangle rectangle)
{
Bitmap bitmap;
try
{
IntPtr windowDC = User32.GetWindowDC(handle);
IntPtr compDC = Gdi32.CreateCompatibleDC(windowDC);
IntPtr bmpPtr = Gdi32.CreateCompatibleBitmap(windowDC, rectangle.Width, rectangle.Height);
IntPtr objPtr = Gdi32.SelectObject(compDC, bmpPtr);
Gdi32.BitBlt(compDC, 0, 0, rectangle.Width, rectangle.Height, windowDC, rectangle.X, rectangle.Y, 13369376);
bitmap = System.Drawing.Image.FromHbitmap(bmpPtr);
User32.ReleaseDC(handle, windowDC);
Gdi32.DeleteObject(bmpPtr);
Gdi32.DeleteObject(objPtr);
Gdi32.DeleteDC(compDC);
}
catch (Exception e)
{
Console.WriteLine(e);
bitmap = null;
}
return bitmap;
}
After that, you continue with image search.