2
votes

I'm developing a program with Java and Sikuli and I want to click on a red image with a specific shape that is located on screen. The problem is that on the screen there is another image with that same shape but different color, blue.

import org.sikuli.script.Screen;

this.screen.type("C:\\Images\\TestImage.png", "a"); // this is what I'm using.

My mouse keeps moving between the two images because it can't tell the difference in color.

2

2 Answers

1
votes

There is no way Sikuli can make the right choice for you. It can only locate a matching are based on your pattern (color in this case). To work around this issue you should provide some reference points that are unique and can be used to "help" Sikuli find the right match. For example, if the pattern you are interested in is located at the left side of the screen, then you can limit the search to the left side of the screen only. Or if you have a unique visual object in the are of interested you can use it as a pivot and look only around it.

On top of that, if you have few similar items appear in some ordered fashion (one under another for example), you can let Sikuli find all of them, calculate their coordinates and select the object you need based on these coordinates.

0
votes

Here's something that might help. Create a Region and try to find the image in that region as in example in the link http://seleniumqg.blogspot.com/2017/06/findfailed-exception-in-sikuili-script.html?m=1