Image recognition without the mouse cursor

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
jackrabbit
Posts: 47
Joined: Wed Mar 18, 2015 10:06 pm

Image recognition without the mouse cursor

Post by jackrabbit » 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;
        }

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Image recognition without the mouse cursor

Post by krstcs » Tue Jun 02, 2015 1:55 pm

Why not just add a mouse movement to get the mouse out of the way right before your validation?
Shortcuts usually aren't...

jackrabbit
Posts: 47
Joined: Wed Mar 18, 2015 10:06 pm

Re: Image recognition without the mouse cursor

Post by jackrabbit » Tue Jun 02, 2015 2:57 pm

Good idea, the solution was too obvious !!!