← Back to team overview

sikuli-driver team mailing list archive

[Question #240213]: How to know a specific image found on a if exists with an array

 

New question #240213 on Sikuli:
https://answers.launchpad.net/sikuli/+question/240213

Hello, i have this part of my code. I already posted it here a few days ago 
(https://answers.launchpad.net/sikuli/+question/239619) and now i have other problems.
I have this array (ha =[]) with some images that i use to find on 2 determined regions (rHa and rHb). The code is working fine, but i want to know if there is any way to know which image my "if (existsAny(rHa, ha)" found. I mean if it found something i want to know what exactly.
Sorry i don't know how to explain it better and engish is not my 1st language.
Hope you guys understand what i mean.
Thanks


rHa = Region(Region(858,644,120,97))
rHb = Region(Region(952,643,105,97))
Settings.waitScanRate = 500 # release brake for the exists
rF= Region(Region(920,890,252,116))#trigger region
Settings.waitScanRate = 3 # reset to normal

mH = (Pattern("mH.png").similar(0.99))
mO = (Pattern("mO.png").similar(0.99))
mP = (Pattern("mP.png").similar(0.99))
mS = (Pattern("mS.png").similar(0.99))
kH = (Pattern("kH.png").similar(0.99))
kO = (Pattern("kO.png").similar(0.99))
kP = (Pattern("kP.png").similar(0.99))
kS = (Pattern("kS.png").similar(0.99))
nH = (Pattern("nH.png").similar(0.99))
nO = (Pattern("nO.png").similar(0.99))
nP = (Pattern("nP.png").similar(0.99))
nS = (Pattern("nS.png").similar(0.99))

ha = [] # <---- this array
ha.append(mH)
ha.append(mO)
ha.append(mS)
ha.append(kH)
ha.append(kO)
ha.append(kS)
ha.append(nH)
ha.append(nO)
ha.append(nS)

nh = [] #m (I use this later)
nh.append(mH)
nh.append(mO)
nh.append(mP)
nh.append(mS)

no = [] #k (I use this later)
no.append(kH)
no.append(kO)
no.append(kP)
no.append(kS)

np = [] #n (I use this later)
np.append(nH)
np.append(nO)
np.append(nP)
np.append(nS)

def existsAny(reg, imageList):
    for img in imageList:
        if (reg.exists(img, 0)):
            return True
    return False

count = 0
while (count < 1000):
    rF.wait(Pattern("trigger.png").similar(0.90), FOREVER)#trigger
    img = Screen(0).capture(Region(959,774,80,33))
    import shutil
    shutil.move (img, 'c:/a/x(%d).png' % count)
    count = count + 1
    
    if (existsAny(rHa, ha) and existsAny(rHb, ha)):
        #print the img that the above if found <------ HERE
        click(Region(1332,817,74,34))
        click(Region(1391,908,215,83))
    else:
        click(Region(882,849,340,166))#clicking the trigger restarts the loop.

Again, thanks!

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