How to loop in Sikuli so that it keeps on typing for n number of times.

Asked by Akhil Latta

I want to put in a loop,this will keep on typing in the given area for n number of times.

Question information

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

Python loop constructs:

--1. while <some condition>:

--2. for entry in entries:

the statements inside the loop have to be indented properly.

examples:

# loops forever
while True:

you have to use a break somewhere inside the loop to end it
if not exists(img, 0): break
would end the loop, if img is not longer visible

# loops as long as condition is true (image is found)
while exists(img, 0):
   click getLastMatch()
   type("some text"+Key.ENTER)
   wait(3

# loops n times
for n in range(10) # 10 times, n will be 0 to 9

# loop through a list
myListFixed = (item1, item2, item3, item4)
for entry in myListFixed:
   print entry
   while not exists(img, 0): wait(1)
   click getLastMatch()
   type(e+Key.ENTER)
   wait(3)

more info: Python docs

Revision history for this message
Tsung-Hsiang Chang (vgod) said :
#2

This question seems to be a FAQ. Raiman, can you put this into a FAQ in the documentation?
Thanks.

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

Hi Sean,

yes we can ;-)

I will boost it up a little bit.

Raimund

Am 14.01.2011 um 17:05 schrieb Tsung-Hsiang Chang:

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

Tsung-Hsiang Chang posted a new comment:
This question seems to be a FAQ. Raiman, can you put this into a FAQ in the documentation?
Thanks.

--
You received this question notification because you are an answer
contact for Sikuli.

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

RaiMan suggests this article as an answer to your question:
FAQ #1437: “How to repeat something in a Sikuli script (make loops)”.

Can you help with this problem?

Provide an answer of your own, or ask Akhil Latta for more information if necessary.

To post a message you must log in.