Image Search on background window (inactive, minimized on system tray)

01/19/2018 15:53 lenclstr746#1
It's possible ? emgu cv or open cv ?
01/19/2018 18:26 Serraniel#2
#moved
01/20/2018 13:43 Xio.#3
Quote:
Originally Posted by lenclstr746 View Post
It's possible ? emgu cv or open cv ?
Depends on the window. If its DirectX or OpenGL it most likely suspends the rendering while in bg.
01/25/2018 15:28 YatoDev#4
A method i prefered when i made pixel bots is to move the window out of the visible screen bounds and change it's window style and ex style class to make it stay active.
Then you may use a window hook to force it stay there and not gain focus.
After that you can send window messages to force inputs without affecting the end user.

and: [Only registered and activated users can see links. Click Here To Register...]
is what i used years ago.
02/18/2018 08:59 exane^#5
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.