While Loop with region.exists(IMG) doing more loops than needed

Asked by Tepedino

This question might be easier for em to understand what am I doing wrong (and with ebtter feedback since I'll be using my own laptop for this.

I'm doing the following while loop:

while r.exists(img1):
    t = r.find(img1)
    dragDrop(t, img2)

where r is a region I set like this: r = find(img3).below()
img1 appear more than once in the r region I defined
img2 is an area outside the r region
(Dunno If I told unecessary stuff but rather add than ommit)

But when I check the log I'm creating, what I got is a FindFailed, informing that it can't find img1 on the screen.
added a simple counter to check how many times I'm doing the loop. It was expected that this loop would occur 16 times, but is doign at least 17 (probably would happen again, but it stops on 17 tries)

Assuming the while was wrong, tried to fix it, check the preview and only the 16 targets I wanted are being compared in the preview.

By now I'm using a second route for my test to work (since I know there is only 16, I'm doing a loop limited up to 16 times), bur would liek to udnerstand what I'm missing to fix the first idea I had.

Thanksm,

Augusto.

Question information

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

I apologize for the question being done here, as I just found a similar problem with my limited loop and noticed that I forgot one thing that I learned from other tests: WAIT!

added a wait(1) in the end and it was crucial, since the window only removes the img1 from the r region AFTER the drop, so without the was still finding it.

Sorry for the problems, btu it might help people int he future (I hope D=)

Thanks,

Augusto.