Page 1 of 1

Image recognition without the mouse cursor

Posted: Mon Jun 01, 2015 10:27 pm
by jackrabbit
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;
        }

Re: Image recognition without the mouse cursor

Posted: Tue Jun 02, 2015 1:55 pm
by krstcs
Why not just add a mouse movement to get the mouse out of the way right before your validation?

Re: Image recognition without the mouse cursor

Posted: Tue Jun 02, 2015 2:57 pm
by jackrabbit
Good idea, the solution was too obvious !!!