Check for 2 images in 1 region

Asked by Conor Lavelle on 2018-04-11

Hi,

I am new to sikuli but I am trying to get a script to wait for either image A or image B to appear in the same region.

type(Key.F8)

while not REGION.exists(img1) or REGION.exists(img2):
      wait(0.5)
type(Key.F8)

I am not sure whether I need to include to while not statements or if I am way off the mark but any help would be greatly appreciated!

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
Conor Lavelle
Solved:
2018-04-11
Last query:
2018-04-11
Last reply:
2018-04-11
RaiMan (raimund-hocke) said : #1

more verbose but clearer:

while True:
   if REGION.exists(img1, 0) or REGION.exists(img2, 0): break
   wait(0.5)
type(Key.F8)

For such situations it is vital to use exists(img, 0): the waittime 0 tells exists() to not wait 3 seconds (the standard) but come back after the first search try (which depending on the sizes might only be some 10 milliseconds)

Conor Lavelle (clavelle123) said : #2

Hi Raiman,
Thanks for your reply!

type(Key.F8)
while True:
    if Region(402,465,298,280).exists(img1,0) or Region(379,489,272,203).exists(Pattern(img2),0):
        wait(0.5)
type(Key.F8)

This is what I have now but it still is not hitting f8 when the image appears!

RaiMan (raimund-hocke) said : #3

go back and read again - you did not get it all ;-)

the break was really intended!

Conor Lavelle (clavelle123) said : #4

Thanks! All working now!