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

eduardobedoya gave more information on the question:
Hi Raiman, I've read the python tutorial, and Im currently reading the sikuli 
one
I got the script to do what I was intending to, but it takes 6 seconds to 
complete, I would like to double the speed.
I guess I have some useless stuff cluttering the script, please could you take 
a look at it and tell me if there could be some fixes?
Thanks Advanced, this is my script...

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

WhtNumImg = 0
try:
    matches = list(findAll(Pattern("1429333732294.png").exact()))
    WhtNumImg = len(matches)
except FindFailed:
    pass #nothing to do
if WhtNumImg > 0:
    sortedMatchesA = sorted(matches, key=lambda m:m.y) # sorts top to bottom

BlkNumImg = 0
try:
    matches = list(findAll(Pattern("1429334230870.png").exact()))
    BlkNumImg = len(matches)
except FindFailed:
    pass #nothing to do
if BlkNumImg > 0:
    sortedMatchesB = sorted(matches, key=lambda m:m.y) # sorts top to bottom

WhtStartImg = 0
try:
    matches = list(findAll(Pattern("1429334355293.png").exact()))
    WhtStartImg = len(matches)
except FindFailed:
    pass #nothing to do
if WhtStartImg > 0:
    sortedMatchesC = sorted(matches, key=lambda m:m.y) # sorts top to bottom

BlkStartImg = 0
try:
    matches = list(findAll(Pattern("1429334504677.png").exact()))
    BlkStartImg = len(matches)
except FindFailed:
    pass #nothing to do
if BlkStartImg > 0:
    sortedMatchesD = sorted(matches, key=lambda m:m.y) # sorts top to bottom

# I first tried to apped all matches in this way below, but I it added the 
numbers in this way... 7,0,1,1
#AllImg=[]
#AllImg.append(WhtNumImg)
#AllImg.append(BlkNumImg)
#AllImg.append(WhtStartImg)
#AllImg.append(BlkStartImg)

# Instead combining all matches in this way below give the result 9 instead of 
7,0,1,1 (the same applied to AllsortedMatches)
AllImg = WhtNumImg + BlkNumImg + WhtStartImg + BlkStartImg

AllsortedMatches = sortedMatchesA + sortedMatchesC + sortedMatchesD

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

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

print "AllImg:", AllImg

Beasides I still have a little bug in my script above:
The second image to find (sortedMatchesB) doesn't appear in my screen, and when 
this happens, if I add sortedMatchesB to AllsortedMatches I get an error saying 
that sortedMatchesB doesn't exists. In my screen every A, B, C, D image may 
appear or may not, how can I add them even if they are not found in screen, do 
I just create a variable sortedMatchesB = 0???
Could restricting the search area improve the script speed?

Thanks Advanced.

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

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to