Random click region (no images)

Asked by xyz_User

Trying to basically click randomly within the "r" region - there are no images to look for
Tried this from another topic but it doesn't seem to click within the specified region:

import random
r = Region(246,444,153,113)
locx = int(r.w * random.random())
locy = int(r.h * random.random())
click(Location(locx, locy))

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
Last query:
Last reply:
Revision history for this message
Best Manfred Hampl (m-hampl) said :
#1

Location is a position on the screen, not necessarily in your region, and its position is relative to the screen corner.
see https://sikulix-2014.readthedocs.io/en/latest/location.html

Try

locx = r.x + int(r.w * random.random())
locy = r.y + int(r.h * random.random())
click(Location(locx, locy))

Revision history for this message
xyz_User (userseven) said :
#2

Thanks Manfred Hampl, that solved my question.