FindImagePos is not working correctly for me

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
JasonP
Newbie
Posts: 6
Joined: Mon Sep 22, 2014 11:38 pm

FindImagePos is not working correctly for me

Post by JasonP » Wed Sep 24, 2014 5:14 pm

From everything I have read, FindImagePos is supposed to find all instances of that image on a page that is visible and store them in an array.

I am trying to get it to find the instances of an image but even through I have 2 or 3 instances showing, it only finds 1 instance. If I make it so that only one instance is on the screen regardless of the position, it finds it just fine. However, if I put 2 instances on the screen then sometimes it finds the top instance and sometimes it finds the bottom instance but it always still only finds one instance.

My goal is to find the instance that is closest to the bottom of the page and click on that instance.

Here is the code that I am using:

Code: Select all

Let>WSI_TIMEOUT=240
//Wait for 
WaitScreenImage>%BMP_DIR%\image_1.bmp,0.7,CCOEFF

//Find and Right Click Middle Right of 
FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0.7,8,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
    Let>k=NumFound-1
  MouseMove>XArr_%k%,YArr_%k%
  MessageModal>NumFound
  //RCLick
Endif
Any suggestions?

Thanks,

Jason

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1380
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: FindImagePos is not working correctly for me

Post by Dorian (MJT support) » Wed Sep 24, 2014 11:32 pm

Hi Jason,

It's only finding one because you're using COEFF. Try EXACT.

From the helpfile entry for FindImagePosition :

If using CCOEFF matching (the default) only the most likely result is returned and so there will be only one result in X_Array_0 if a match is found. If using EXACT matching multiple results may be returned. The first match is stored in Y_Array_0, the second in Y_Array_1, etc.
Yes, we have a Custom Scripting Service. Message me or go here

JasonP
Newbie
Posts: 6
Joined: Mon Sep 22, 2014 11:38 pm

Re: FindImagePos is not working correctly for me

Post by JasonP » Fri Sep 26, 2014 1:11 pm

Thanks so much for this information. I didn't realize that. I will give that a try.

Jason

fthomas
Pro Scripter
Posts: 91
Joined: Fri Oct 03, 2008 6:40 pm

Re: FindImagePos is not working correctly for me

Post by fthomas » Mon Sep 29, 2014 2:56 pm

Thanks, I didn't know that either, lol.

Frank

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts