← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #169982]: while not exists(image, FOREVER) seems not to work

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--- Your script

Again: if this is still your script:
while True:
   while not RegionA.exists(Blue.png,FOREVER):
      RegionB.wait(Yellow.png,FOREVER)
      click(RegionB.getLastMatch())

then Yellow should never be clicked.
Since your script here is not your original script (Blue.png and Yellow.png will make a syntax error), I think your script has a bug that is not obvious (because it seems to do something).

In the IDE it should look like this (and it should not do, what you think it should do)
while True:
<tab>while not RegionA.exists(Blue.png,FOREVER):
<tab><tab>RegionB.wait(Yellow.png,FOREVER)
<tab><tab>click(RegionB.getLastMatch())

where <tab> means: having the text left justified, use one tab for each
<tab> to indent it.

-- your situation
still not clear what you want:

this seems to be clear: when yellow appears, it should be clicked, but
the dependency from Blue is not clear.

for Blue I see 2 options:
1. should it only be clicked, if Blue is visible at the same time?
2. or should it only be clicked, if Blue has been visible before at least once? (does not matter if Blue is still visible now)

-- for option 1:

while True:
<tab>regionB.wait(Yellow, FOREVER)
<tab>if regionA.exists(Blue, 0):
<tab><tab>click(RegionB.getLastMatch())

-- for option 2:

isBlue = False
while True:
<tab>if not isBlue and RegionA.exists(Blue, 0): isBlue = True
<tab>if regionB.exists(Yellow, 0):
<tab><tab>if isBlue: 
<tab><tab><tab>click(RegionB.getLastMatch())
<tab><tab><tab>isBlue = False
<tab>wait(1)

Another question: If you successfully (as you think it should be) clicked Yellow, should you wait until Yellow vanishes before you start allover again or does it vanish with the click? 
If it makes sense, add this after the click(RegionB.getLastMatch())
<tab><tab>RegionB.waitVanish(Yellow, 10) # or another time that makes sense (option 1)
<tab><tab><tab>RegionB.waitVanish(Yellow, 10) # or another time that makes sense (option 2)

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