Image recognition without the mouse cursor
Posted: Mon Jun 01, 2015 10:27 pm
I think I have a problem with the mouse cursor when I attempt an image recognition. It the mouse cursor is located in the image area, the recognition fails. If I move the mouse away from the image, on the next attempt it works. I am using Ranorex 5.2.2.
Code: Select all
...
Report.Log(ReportLevel.Info, "Wait", "Looking for 'CTRL-ALT-DEL' image.");
if (! ImageFound(@"CtrlAltDel.png", 10000))
throw new ValidationException("Fail to find image.");
...
private bool ImageFound(String ImageFile, int Wait)
{
const long TicksPerMsec = 10000;
Bitmap Bmp = Imaging.Load(@"..\..\Images\" + ImageFile);
long Timeout = System.DateTime.Now.Ticks + (Wait * TicksPerMsec);
bool ImgFound = false;
while (System.DateTime.Now.Ticks < Timeout && ! ImgFound) {
ImgFound = Imaging.Contains(MyRepo.FormConsole.Self, Bmp);
Delay.Milliseconds(100);
}
return ImgFound;
}