← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #259577]: Is there a way to discard the background while image compareing

 

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

RaiMan proposed the following answer:
@Eugene
thanks for your solution.
... I have some optimisations:

# import time # not necessary since already done by Sikuli

def findAny(thelist, theregion=SCREEN, timeout=False):
    if not timeout:
        timeout=theregion.getAutoWaitTimeout()
    res=None
    exit_time=time.time()+timeout
    while not res and time.time()<exit_time():
      for s in thelist:
        res=theregion.exists(s,0)
        if res:
          break
    return res

#usage:
thereg=Region(324,321,648,429)
btn = findAny(["btn_bg1.png","btn_bg2.png","btn_bg3.png"], 20) 
if btn; 
    btn.click()
else:
    # do some error handling

... since the return value of findAny might be None, None.click() would
produce an odd exception.

Region.getAutoWaitTimeout() returns the global AutoWaitTimeout, if the
Region does not have its own value at this time (the specific Region
value is set to the global at init of the Region).

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