← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #262834]: Speeding Up the Key Listening in a Game

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Since in this situation there is no need to wait for the symbol, since
one of the 3 variants must be there, since the user pressed alt-z
because he has seen it ;-), we can use exists(image, 0) which only does
one search and comes back immediately with the result:

def letsSpam(event):

    if reg.exists(alpha, 0):
        keyDown("q")
        wait(.2)
        keyUp("q")

    elif reg.exists(gamma, 0):
        keyDown("w")
        wait(.2)
        keyUp("w")

    elif reg.exists(beta, 0):
        keyDown("e")
        wait(.2)
        keyUp("e")

With your version, if the symbol is neither alpha nor gamma, it takes mor than 6 seconds (2 times standard waiting time of 3 seconds).
Now it will take a few milliseconds.

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