Java: How to use an anonymous Pattern object in click method

Asked by Jeremiah Jacquet

is the last argument in the click method the similarity index?

s.click(arg0, arg1);

 if yes, what is the most accurate setting value? 10?

if not, how can I set the similarity index to its most accurate settings on a global level in Java?

If there is no global way to do that how to I call it every time there is a click method?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

No, the second argument of click(image, mod) is the KeyModifier code for the mod key to be pressed together with the mouse click(SHIFT, ALT, CTRL, CMD).
So click(image) and click(image, 0) do the same (no mod key pressed).

-- global min similarity
Settings.MinSimilarity = 0.x
the maximum value that should be used is 0.99 (1.0 has a bug)

Nevertheless, it is not recommended, to use a global value above 0.9, to avoid too much FindFailed situations.

-- search with a special minSimilarity
use the Pattern class, to produce search objects with min similarity and a target offset attributes.
s.click(new Pattern(image_string).similar(0.99))

more details: http://doc.sikuli.org/javadoc/index.html

Revision history for this message
Jeremiah Jacquet (jeremiahjacquet) said :
#2

i tried this:
s.click(new Pattern("imgs/SomeImage.png").similar((float) 0.99));

Eclipse tells me that The method click(PSRML, int) in the type Region is not applicable for the arguments (Pattern). The option it give me is Change to showClick (..)

I also tried simplifying the method
s.click("imgs/ConfirmAuthorNanceeSthay.png").similar(.99);
Eclipse tells me The method click(PSRML, int) in the type Region is not applicable for the arguments (String)
This also give me the showClick optional change

trying it with the Pattern class and without ultimately end up with a syntax error and the only option is to use showClick, but even after switching to showClick as a method I then get the following error:
The method showClick(Location) in the type Screen is not applicable for the arguments (Pattern)

Revision history for this message
Best RaiMan (raimund-hocke) said :
#3

s.click( (new Pattern("imgs/SomeImage.png")).similar((float) 0.99));

Revision history for this message
Jeremiah Jacquet (jeremiahjacquet) said :
#4

That works, however go trying to make it less accurate you have to move the float value to .20 or lower. It seem 90-30 values don't really have an impact. Using values from 20 and below are way to inaccurate. Not saying its good or bad because its better to have the most accurate value to insure correct images are being detected. Thanks again RaiMan.

Revision history for this message
Jeremiah Jacquet (jeremiahjacquet) said :
#5

Thanks RaiMan, that solved my question.