← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #237313]: How to scan all screens every time

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Will be available with next version.

Meanwhile you might use your own functions:

# a function aquivalent to exists() 
def myExists(pat, wtime = getNumberScreens()):
    wtime = getNumberScreens() if wtime == 0 else wtime 
    start = time.time()
    screens = [Screen(i) for i in range(getNumberScreens())]   
    while wtime > time.time()-start:
        for screen in screens:
            if screen.exists(pat, 0):
                return screen.getLastMatch()
    return None

# a function aquivalent to find/wait
def myFind(pat, wtime = getNumberScreens()):
    wtime = getNumberScreens() if wtime == 0 else wtime 
    start = time.time()
    screens = [Screen(i) for i in range(getNumberScreens())]   
    while wtime > time.time()-start:
        for screen in screens:
            if screen.exists(pat, 0):
                return screen.getLastMatch()
    raise FindFailed("not found on any screen: " + str(pat))

# usages with click
click(myExists(some_pattern_or_image)) # will simply do nothing on not found
click(myFind(some_pattern_or_image)) # will raise FindFaild exception on not found

# as usual you might save the match
m = myExists(some_pattern_or_image)
if m:
    print "found"
else:
    print "not found"

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