← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #177265]: code works once

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
ok, then lets base on this version, because it is more compact and does
the same:

# block 1
for i in range(10): # repeat 10 times
    click("1320241172682.png")
    wait(2)

# block 2
for i in range(10): # repeat 10 times
    click("1320241215290.png")
    wait(2)

# block 3
for i in range(10): # repeat 10 times
    click("1320241396712.png")
    wait(1)
    click("1320241528063.png")
    wait(2)

If I understand you write, in block1 you click ten times on the same image, that changes, when it is clicked, so in the next turn another of these equal images is clicked.
This should work, when there are always 10 images and if 2 seconds are enough to wait for the clicked image to change.

So lets assume there are max 10 images (might be less):

# block 1
for i in range(10): # repeat 10 times
    if not exists("1320241172682.png"): break
    click(getLastMatch())
    wait(2)

This version will end the block1 loop if no more images are found and
proceed with block2.

A general alternative is:

matches = findAll("1320241172682.png")
for m in matches:
       click(m)

here you would not have to wait for the images to change, because all
images where found with findAll(), before we start to click.

hope it brings you further down true road to Sikuli-Happiness.

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