← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #680146]: How do I get multiple arguments into a class object that I can use in dictionary functions

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
why so complicated?

this simple def will do:

def move(direction, counter = 1):
    if direction < 1 or direction > 4:
        return # do nothing
    key = Key.RIGHT
    if direction == 2:
        key = Key.LEFT
    elif direction == 3:
        key = Key.UP
    if direction == 4:
        key = Key.DOWN
    for n in range(counter):
        type(key)

To make it more readable place this outside the def
RIGHT = 1
LEFT = 2
UP = 3
DOWN = 4

the use it:
move(RIGHT) # one cell
move(DOWN, 3) # 3 cells

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.