Increasing odds of the find( ) routine working?

Asked by Robert

 I am getting inconsistent results with the find( ) routine, especially when finding menu items. In my File menu, I have a Load Solution and a Save Solution. When I scripted a find( Save Solution ) it would often decide that the Load Solution was a good match. I made the snapshot of the Save Solution menu item much larger to include a bunch of white space around it, and now it seems to find it more consistently.

Is there a way to increase the odds that a particular find( ) will work?

Question information

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

There is a problem finding pictures consistently, that contain much text (a bug is reported), as is typical for menu entries.

You may try to extend the capture, to include more grafical information. as long as the center of the capture targets your menu entry, the following click should run.

another method could be to use calculated clicks.
base = find() # a reference pic
mEntry=Match(base.getX()+offsetX, base.getY()+offsetY, width, height, 1)
# relative position of menu entry by setting offsetX/Y (upper left), width/height of menu entry
click(mEntry)

alternatively you could try to access the menus with sequence of type() commands.
look question: https://answers.launchpad.net/sikuli/+question/102492

Revision history for this message
Garrett Bartley (wgbartley) said :
#2

I have found that getting as precise as I can with the screenshot tends to work best for me. Then, if you click on the image within the Sikuli IDE, it will open a smaller window showing you a screenshot of the entire screen and the matches for your reference image. You can then use the slider to adjust the matches. I'm not sure of all the fanciness going on in the background to make it all work, but it has helped me a great deal.

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

Whats going on there, is that using the slider in the small window adapts the similarity between 0 (match nearly everything) and 1 (exact match needed). This turns your image into a Pattern(image).similar(n). This is shown in the IDE with the small number right top with your image icon.

For some captured things it helps to lower the needed similarity (which is 0.7 in the standard and used if you say click(image) without adjusting by using the process you used).

I'm happy with you, that you got it working.

Revision history for this message
Eli Carter (elicarter) said :
#4

RaiMan, you state "There is a problem finding pictures consistently, that contain much text (a bug is reported),"; which bug is that?

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

Can you help with this problem?

Provide an answer of your own, or ask Robert for more information if necessary.

To post a message you must log in.