← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #244750]: setRect in 2 for loops doesn't work

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
surely not a bug, but a combination of timing and logic (I do not see
any sense in that).

For this example there must be some "magic", that takes care, that the
target image at some time after script start appears and the after the
popup is hidden again.

in #1 the while not search_rect.exists("1392034498790.png"): is repeated
every 3 seconds, but during these 3 seconds every about 300 msecs
(waitScanRate) the search is repeated (the given region is rather
small).

but in #2 the while not exists("1392034498790.png"): is also repeated,
but each search during this period might last up to 1 second

So in #1 the probability is high, that the while catches the appear and
hence does not enter the loop body again.

This should always work:
search_rect=setRect(379,163,689,56)
img = "1392034498790.png"
for a in range(1,3):
    while not search_rect.exists(img, 0): # only one search
        wait(1)
    search_rect.highlight(-2) # highlights the match
    popup("exists")

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