← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #149990]: Accuracy of image recognizers and actions sikuli.

 

Question #149990 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/149990

RaiMan proposed the following answer:
Sorry, it is always a risk, to just type script code here, without
having it tested ( not reg.focus() but myApp.focus() )

Here you have a tested snippet, that you have to adapt to your english
environment (I think: Editor = Notepad, Datei = File).

And you get an idea of an alternative approach for your menu problem.

myApp=App("Editor")
myApp.focus()
reg = myApp.window()
reg.highlight(2)
menubar = reg.above(1).below(30).below(20)
menubar.highlight(2)
mDatei = menubar.find("Datei") # text search
mDatei.highlight(2)
click(mDatei)
wait(3) # to give a chance to see the effect

--- you say:
 I'm not sure that it has focus, is seen in 35 seconds video - an application receives the focus when you click on the main menu. Or I do not understand?

Yes, should normally be so. But I had cases with Sikuli clicks, where it
did not work and either a (Sikuli) doubleclick or a switchApp() was
needed. (This problem is also dicussed here from time to time)

--- you say:
 but the problem I described above is found not only in the menu. Sikuli not always accurately determine where to click

per definition and design - Sikuli cannot be "accurate" when searching,
since this process is based on similarity. If something is found, Sikuli
tells you, how similar it is. Only 1.0 normally means that the match is
pixel by pixel identical with the search pattern. So if you cannot be
sure, you have to check the result of a search. So e.g., if you expect
something to be exactly matched, it is not wise, to allow the search
with a similarity below 0.9 or even 0.99.

--- my experience and recommendation
the best way to assure your searches is to restrict the search region to the area, were you expect the visual object to appear. Next is setting a high similar() value and check the match. 
I normally use m = exists(image) and check m before going further, e.g.
menu = exists(menu_image)
if not menu:
   print "menu not found"; exit()
click(menu)

You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.