← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #265152]: Text can be found with region.text() but not with region.exists()

 

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

Description changed to:
Hello,

We're trying to use text recognition, but the results are inconsistent.
Our application windows have tabs and we want to read those tabs to check that the window has opened and that it's the right one.
To do that we've made a region called tabs and we ask it if the right tab exists with tabs.exists("name_of_tab").
With some names it works, and with some names it doesn't.
Because of this we thought that perhaps those names that didn't work couldn't be recognised, so we turned it around and asked tabs to tell us what it saw with tabs.exists().
When we do this it recognises every name perfectly.
How can we get every name to be recognised when using tabs.exists("name_of_tab")?

We use Sikuli 1.1.0
This is our code:

# Find tab Key2Wocas, and turn it into the base region the other regions will be based on
def regio():
    global r
    r = Region(find("Key2Woca.png"))
    r = r.right(27)
    r = r.nearby(10)
    
# Make a new region to the right of the base region. This is where the tabs will be found 
def regio_tabs(): 
    regio()    
    global tabs
    tabs=r.right()
    tabs.highlight(1)
    print tabs.text()  
    
# Check to see if the the right tab exists in the region tabs
def tab_aanwezig(tekst):
     
    regio_tabs()
    t = tekst
    
    if not tabs.exists(t):
        wait(3)

    m = tabs.exists(t)
    if m: 
        print "Tabblad " + t + " is geopend."
    else:
        print "Tabblad " + t + " is niet binnen 3 seconden gevonden; het script wordt gestopt."
        exit()

tab_aanwezig("Basisregistratie")

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