sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #10902
Re: [Question #199220]: while not exists or not exists
Question #199220 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/199220
Status: Open => Answered
RaiMan proposed the following answer:
--- I understand:
As long as neither A nor B are visible C should be clicked.
If either A or B come up, space should be typed and the while loop should end.
This should make it:
while not ( Region(A).exists(A.png) or Region(B).exists(B.png) ):
Region(C).click (C.png)
else:
type(" ")
the condition can be written as (logical rules):
while ( not Region(A).exists(A.png) ) and ( not
Region(B).exists(B.png) ):
the extra brackets in this case are not needed, only to show the
precedence.
whichever is more readable for you.
--- using exists() in conditions
If you use exits this way, you are wasting time:
Since the expressions are evaluated left to right, the first exists() takes 3 seconds, if A is not there. Then the second exists() takes another 3 seconds, if B is not there.
So every click on C is done every 6 seconds.
If this is not your intention, the use exists(image, 0) in these cases. This should take about 1 second for every click turn in your case.
The magic: exists(image, 0) comes back after 1 search trial even if not found.
So I recommend finally:
while not ( Region(A).exists(A.png, 0) or Region(B).exists(B.png, 0) ):
Region(C).click (C.png)
else:
type(" ")
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.