← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #264563]: How to get a final sorted match list after more than one findAll()

 

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

eduardobedoya gave more information on the question:
Yes Raiman, Thanks for the "list.extend(list)" thing
Sikuli IDLE warn me about the need to use an empty list "list=[]" xD
So I fixed the script, but it still takes 6 seconds before any mouse move or hover.
Could restricting the search area improve the script speed? How could I increase speed??

This is my Script:

App.focus("IrfanView")
Settings.DelayAfterDrag = 0
Settings.DelayBeforeDrop = 0
Settings.MoveMouseDelay = 0

try:
    MatchesWNI = list(findAll(Pattern("1429333732294.png").exact()))
    WhtNumImg = len(MatchesWNI)
except FindFailed:
    WhtNumImg = 0
    MatchesWNI = []

try:
    MatchesBNI = list(findAll(Pattern("1429334230870.png").exact()))
    BlkNumImg = len(MatchesBNI)
except FindFailed:
    BlkNumImg = 0
    MatchesBNI = []
    
try:
    MatchesWSI = list(findAll(Pattern("1429334355293.png").exact()))
    WhtStartImg = len(MatchesWSI)
except FindFailed:
    WhtStartImg = 0
    MatchesWSI = []
    
try:
    MatchesBSI = list(findAll(Pattern("1429334504677.png").exact()))
    BlkStartImg = len(MatchesBSI)
except FindFailed:
    BlkStartImg = 0
    MatchesBSI = []

#This below combine the Imgs giving this result [7, 0, 1, 1]
#AllImg=[]
#AllImg.append(WhtNumImg)
#AllImg.append(BlkNumImg)
#AllImg.append(WhtStartImg)
#AllImg.append(BlkStartImg)

#This below combine all Imgs giving this result [7, 0, 1, 1]
#AllImg = [WhtNumImg] + [BlkNumImg] + [WhtStartImg] + [BlkStartImg]

#This below combine all Imgs giving this result 9
AllImg = WhtNumImg + BlkNumImg + WhtStartImg + BlkStartImg

#This below combine all Matches giving a result that can be sorted
AllMatches=[]
AllMatches.extend(MatchesWNI)
AllMatches.extend(MatchesBNI)
AllMatches.extend(MatchesWSI)
AllMatches.extend(MatchesBSI)

#This below combine all Matches giving a result that can be sorted
#AllMatches = MatchesWNI + MatchesBNI + MatchesWSI + MatchesBSI

if AllImg > 0:
    SortedAllMatches = sorted(AllMatches, key=lambda m:m.y) # sorts top to bottom


#for item in FinalsortedMatches:
#    hover(item)

for index, item in enumerate(SortedAllMatches):
    hover (item)
    print index, item

print "AllImg:", AllImg

Thanks Advanced.
Please tell is there is something else I could do to improve speed in this code.

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