Reputation: 1
So I want to capture one image, image s, which is always in the same region. It then disappears and may or may not re-appear in a different region.
I would like the program to capture the first time it appears and if it re-appears in the other region, then click a set of buttons otherwise move to a different function.
The other thing is image s changes each time the function is called but it remains in the same location.
Below is my code:
def playLoop():
s = capture(firstRegion)
warnBox = exists("1443867801301.png")
if not warnBox:
if exists("1443867813008.png"):
click(x)
playLoop()
else:
if secondRegion.exists(Pattern(s).similar(0.8)):
wait(3)
click(x)
playLoop()
else:
loopLoop()
else:
doubleClick(y)
if secondRegion.exists(Pattern(s).similar(0.8)):
wait(3)
click(x)
playLoop()
else:
loopLoop()
I get no errors, however it doesn't seem to work. Any ideas?
Upvotes: 0
Views: 2559
Reputation: 2505
To see if region1 exists in region2 you could use if region2.exists(region1) then
.
Upvotes: 0
Reputation: 411
Finally, if you want to get the numer of times, you can pass a variable to the function:
def playLoop(times,x,y):
s = capture(firstRegion)
t = find(s)
if times==0:
warnBox = exists("1443867801301.png")
if not warnBox:
if exists("1443867813008.png"):
click(x)
times+=1
playLoop(times,t.getX(),t.getY())
if times != 0:
warnBox = exists("1443867801301.png")
if not warnBox:
if t.getX() != x or t.getY() != y: #different location
doSomething()
else:
otherFunction() #same location
times+=1
PD: Sry if my english isn't good :)
Upvotes: 1