Question #186261 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/186261
Status: Open => Answered
RaiMan proposed the following answer:
nice try, but that does not work this way ;-)
using
up = type(Key.UP)
runs the type command in this moment and assigns either 0 or 1 (the
returned value) to your variable.
Try this one:
import random
def randomType(direction):
if direction = "up": type(Key.UP)
elif direction = "down": type(Key.DOWN)
elif direction = "left": type(Key.LEFT)
elif direction = "right": type(Key.RIGHT)
else: print direction, ": invalid direction"
move = ( "up", "down", "left", "right")
nav = random.choice(move)
print "now moving", nav
randomType(nav)
Depending on what your final goal is, you might move all into the def():
import random
def randomType():
nav = random.choice( "up", "down", "left", "right")
print "now moving", nav
if direction = "up": type(Key.UP)
elif direction = "down": type(Key.DOWN)
elif direction = "left": type(Key.LEFT)
else: type(Key.RIGHT)
or even shorter without a print:
def randomType():
type(random.choice(Key.UP, Key.DOWN, Key.LEFT, Key.RIGHT))
--
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