← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #237464]: issue with loop

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--- Create/find/click
You have some blocks of this structure.

I understand this:
# starting with # means comment - other lines are real code in version 1.0.1

#Create Region # defines the area/region of interest, where you expect to find some image
# alternatives
reg = Region(x, y, w, h) # defines a fixed region at top-left (x,y) with width w and height h
reg = selectRegion() # set the region interactively
reg = some_other_region_or_match.below(200).grow(0, 100, 0, 0) # define a region relative to another
# this case: 
#below: the region below the given region's bottom border same width and height 200
# grow: add 100 to width on the right side
# alternative 3 is always the best choice

reg.find (img) # searches for img in region reg (not on whole screen as find(img) would do)
# crashes with FindFailed if image not found within 3 secs
# otherwise stores the match region with the region and returns it     
reg.click() # would click on the last found match in region reg

# not crashing alternative:
if reg.exists(img):
    reg.click()
else:
    # do something else
    print img, "not found in region", reg, " --- terminating"
    exit(1)

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