how to loop

Asked by Benjii Tiu

i wanted this set of group of loop to be done 100 times. How do i do that? i could copy and paste them a 100 times, but that would be a waste if there is an easy way to do it. Its so hard to find simple answers. I had to register just to ask this question.

click("1344015944371.png")
sleep(5)
click("Like.png")
sleep(5)
click("U.png")
click("1344016163786.png")
sleep(5)
click("1344016205115.png")
sleep(5)

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

The simpla answer lies in the fact, that Sikuli uses Python language for scripting (which is interpreted by Jython at runtime, the Java based Python interpreter).

Another source for simple answers are the docs and the faqs here.

Soin this case look faq 1437

and if new to Python language: faq 1858

Revision history for this message
Benjii Tiu (jn-tongko) said :
#2

I saw that faq 1437 and i don't understand it...

Could you just put the code on how to put the loop in this group? its like this, i wanted to do it 100 times, or endless?

loop start
click("1344015944371.png")
sleep(5)
click("Like.png")
sleep(5)
click("U.png")
click("1344016163786.png")
sleep(5)
click("1344016205115.png")
sleep(5)
loop end

Revision history for this message
Best RaiMan (raimund-hocke) said :
#3

Only seeing a faq is surely not enough to understand it.
Some playing around with the given examples is needed at least.

I would have expected at least a may be unsuccessful trial.

But since it is nearly weekend, here you are:

for i in range(100):
    click("1344015944371.png")
    sleep(5)
    click("Like.png")
    sleep(5)
    click("U.png")
    click("1344016163786.png")
    sleep(5)
    click("1344016205115.png")
    sleep(5)

mind the indentation ( faq 1800).

hope it works ;-)

Revision history for this message
Benjii Tiu (jn-tongko) said :
#4

Yehey.... your trick worked... Im just new to this sikuli, so i wanted some samples just to get through the loop.... actually, i had a sample here, but did not properly know how to do it correctly... this is the sample i found in some forums.

for i in range(10):
    if exists():
        click()
        sleep(5)
    else:
        click()
        sleep(5)
        click()
        sleep(5)

so to properly work, they don't need to be on the same line, you need to click tab, so that it would work.... ah!