← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #162725]: random click

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--- click somewhere
m = wait(image)
click(m.getCenter().right(x).below(y))

-- m is the found match.
-- click(m) would click the center, getCenter() returns this pixel position
-- right(x), below(y) add x to the current x position, y to the current y position and return a new pixel position
-- if you set x and y to the respective values negative or positive, you might click wherever you want

--- if you want to randomize x and y:
use Python module random:
import random # at beginning of script

# use this where ever needed
x = random.randint(0,m.w)-int(m.w/2)
y = random.randint(0,m.y)-int(m.y/2) 

now you have random x and y values, every time it is used

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