How to count how many times one image is found on the screen

So I have a simple function that creates a certain number of circles on the screen. All the circles are identical. I want to use a image of one of the circles and then see how many copies of that image are found on the screen.

The reason for this is because the number of circles that will be placed on the screen will change each time. Any ideas on how I could do this?

If your circles are truly identical, then once you’ve captured an image of your circle, you can get a count of how many there are with this call:

put the count of EveryImageLocation("myCircle")

Now, since you say that you’re drawing these circles, I would not be surprised if they are not actually identical in the pixel-for-pixel way that Eggplant considers things identical, in which case this won’t actually work, but try it and let us know how it goes.

Thanks for the quick response.

Tried it out and it worked. I created a function to make the circles so they are all identical.

I had to use the EveryImageLocation() like this.

set circlecnt to 27

Click (700,700)

put the number of items of EveryImageLocation(“Result02”) into circlesfound

if circlesfound equals circlecnt then


end if

Glad it worked, Jeff. I understood that you were using a function to generate the circles, but sometimes the starting point can affect the actual pixels that are used to display a shape or character. This is especially true if any sort of smoothing or anti-aliasing is being applied. I’m glad that this was not an issue in your case.