How to make sikuli find image for a new search?

Asked by Diana

It looks like sikuli search the image only once. After it finds the image, the location is saved. Next time it will use this location, not start a new search.
But I meet this case:
for i in alist:
    click( textbox)
    paste(i)
    click(create)
when i is created, the textbox position is changed. But for next one, sikuli still click previous position. So it fails.
Does any way let sikuli do a new search in each loop?
Thanks

Question information

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

when using
click(some_image)

where some_image either is a string containing a valid image file name or a variable containing a string containing a valid image file name, then in all cases a new search is done.

Only if you intentionally use the result of a previous find or the region's last match, then this location on the screen is used

match = find(some_image)
for i in range(3):
    click(match)

or this
click(some_image)
match = getLastMatch()
for i in range(3):
    click(match)

will always click the same location match, since the find is not repeated intentionally.

To get better help, you should paste your real code.

Revision history for this message
Diana (fan-ding1) said :
#2

Please see my code:
dic={'d1':'name1','d2':'name2'}
for d,t in dic.iteritems():
     click(match)
     paste(t)
     click(d)
     click(add)

when add a new item, match textbox is changed the position, but each time, sikuli always click the same position for match.

Revision history for this message
Diana (fan-ding1) said :
#3

My code can work now. Just add wait(2) in the loop.