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

iu am using sikuli version 1.1.3
I want to find image pattern and type out accordingly
only 6 pattern: up arrow, down narrow, left arrow, right arrow, letter j and 
letter k


the image pattern could be up,up,k  the code will detect and type up,up,k
the image pattern could be down,left j the code will detect and type out 
down,down,j

my code is to find the image and sort it using the x coordinate, then type out 

patterns = 
[Pattern("up.png").similar(0.85),Pattern("down.png").similar(0.85),Pattern("left.png").similar(0.85),Pattern("right.png").similar(0.85),Pattern("j.png").similar(0.85),Pattern("k.png").similar(0.85)]
start = Pattern("start.png").similar(0.90)
mm = []
all_icons = []

def by_x(match):
   return match.x
       
def by_sort(icons):
    # sort the icons by their x coordinates and put them into a new variable 
sorted_icons
    sorted_icons = sorted(icons, key=by_x)       
    for icon in sorted_icons:
        popup(icon.getIndex())       
    
def recycleAll(x,name): 
# --- using exception handling
# every not found in the try block will switch to the except block    
    try:
        icons = findAll(x)
        while icons.hasNext(): # loop as long there is a first and more matches
            all_icons.append(icons.next())
        all_icons.append(name)
        icons.destroy()
    except FindFailed:
        pass # we miss it

while True:#This is the main loop of the application. 
    if exists(start):
        for x in patterns:
            recycleAll(x,x.getFilename())
        by_sort(all_icons);
        #by_key(mm)
        mm = []
        all_icons = []
        pass
    else: 
        pass
        


Having problem after sorting them by x coordinate, not sure how to detect and 
type

-- 
You received this question notification because your team Sikuli Drivers
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