← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #233860]: Region.find or Region.findAll problem in Sikuli Version 1.0.1

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
You are not using the defined region to restrict the searches:

click() works on the whole screen

but 
reg.click()
would only search in the Region reg

this should principally work:

reg = Region(413,248,680,510)
while reg.exists("1376053585710.png"):
    click(reg.getLastMatch())
    find("1376053640208.png")
    click("1376053656049.png")
    find("1376053684932.png")
    click("1376053695853.png")
else:
    print("no more found)

comments:
-- exists
in while and if constructs use exists instead of find, since it avoids the unnecessary exception if not found 

-- getLastMatch
The last succesful find operation is remembered by a region and can be used to act on it with click(reg.getLastMatch()), which on top avoids an additional search (which exactly is your problem in this case).

--- BTW: if 1376053585710.png ...
... is your same icon, that might be there multiple times in the Region reg, than you loop will only work, if the processed icon vanishes or changes in a way, that it is no longer found, after being processed. Otherwise you might always get the same icon with 
 reg.exists("1376053585710.png").

The only chance to solve this is findAll() (see docs)

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