sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #41969
[Question #578448]: if exists (A, 0), if exists (B, 0) not working within a loop
New question #578448 on Sikuli:
https://answers.launchpad.net/sikuli/+question/578448
Hey Raimund,
Thanks for your help the last time! I have been playing around with Sikulix since the last time i got a reply from you and it has been an amazing experience! Have a number of questions I would like to get your advice on, but thought I would space them into individual questions so that it will be useful to file into the faq.
My program is intended to automize a game. How the game goes is as follows.
Loop
1) Start scenario
2) Scenario runs for ~ 2minutes
3) Success (1st possible Outcome) - followed by a variation in rewards which require their own respective actions
4) Failure (2nd possible Outcome) - press some buttons to move on to next run
5) Press End scenario to reach start scenario page - potential request to refill Energy level
The issue is sometimes the Success page appears but the programme does not respond. I think it might have to do with my coding of the two possible outcomes statement, as below. I have tried using exists(image,0) and exists (image,1-5) to no avail. I have checked the images multiple times when the program failed to respond, and the images were matched to those i have saved, so that should not be the issue.
My guess of the problem:
waitUntil = time.time()+ 120
while time.time() < waitUntil:
if rewardicon.exists(reward image,0):
elif reg2.exists(failed image,0):
Script:
#Begins scenario
for runs in range(1,10):
if regStart.exists(image):
time.sleep(0.5)
click(pointA)
time.sleep(100)
rewardicon = (region of reward image)
reg2 = Region(764,501,180,101)
waitUntil = time.time()+ 120
while time.time() < waitUntil:
if rewardicon.exists(reward image,0):
time.sleep(1)
doubleClick(pointA)
time.sleep(1)
doubleClick(pointA)
time.sleep(1)
doubleClick(pointA)
#different rewards and what actions to take with each
if regphone.exists(Image):
regphone.click(Image)
time.sleep(0.5)
break
if regphone.exists(Image):
regphone.click(Image)
time.sleep(0.5)
click(PointB)
time.sleep(0.5)
break
elif region.exists(Image,0):
regphone.click(Pattern("1490061651602.png").similar(0.61))
runes=runes+1
time.sleep(0.5)
break
break
#Failed scenario (no reward)
elif reg2.exists(failed image,0):
time.sleep(1)
click(PointA)
time.sleep(1)
break
#Press End scenario to reach start scenario page
reg3 = Region()
if reg3.exists(image):
time.sleep(1)
click(Replay)
#If require top up of Energy
reg4 = Region()
if reg4.exists(Image):
time.sleep(1)
click(PA)
click(Replay)
time.sleep(1)
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.