← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #216473]: Loop through list

 

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

Description changed to:
Hello,

Before I began, I just want to let it known that I have read FAQ 1437,
and even look up Python tutorials elsewhere; however, I'm stuck. I'm
completely new to programming/scripting.

# --- loop through a list
myListFixed = (11, 22, 33, 44)
for entry in myListFixed:
   print entry
   lastEntry = entry
   while not exists(img, 0):
      wait(1) # we wait for the entry field
   type(getLastMatch(), e+Key.ENTER)
   wait(3)
   # now the next entry
print "the last entry was:", lastEntry

Using the above example, when I try to run the script, I received an
error that states "e" is not defined. I even tried "entry+Key.ENTER"
without luck.

My problem: I have a list that I would like to be typed in sikuli.
First, the script will click a few buttons, then a text field, and then
enter the 1st item on the list, press enter.  Then, repeat from step 1,
with the exception that 2nd item will be entered this time instead of
the first item.

For example:

click(".png") # Step 1, Button
click(".png") # Text field
myListFixed = (11, 22, 33, 44) 
for entry in myListFixed:
      lastEntry = entry
   while not exists(img, 0):
      wait(1) # we wait for the entry field
   type(getLastMatch(), e+Key.ENTER)  # I would like to loop through myListFixed
   wait(3)
Restart from step 1 # now the next entry

While we are at loop and list, it is possible to loop array such as
this:

List1= [1,2,3]
List2= [a,b,c]

And to have sikuli type "1" in the first text field, and "a" in the
second text field, then repeat the process entering "2","b", etc...

Thank you very much for your help.  In the meantime I will continue to
search for the answers on the board.

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