SikuliX Scripts for Bluestacks

Asked by Phil

Hi all,

For example I have a button I want SikuliX to click on. This button is between 744X,1043Y and 799X,1077Y. I want SikuliX to click within these coordinates but on random. Like with every click SikuliX presses on that button, it does so on a different pixel (the game I will use SikuliX for detects when you keep pressing on the same spots)

How can I let SikuliX do that?

I hope you understand my problem.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Roman Podolyan (podolyan-roman) said :
#1

1) import random Python module
2) get location of top left corner
3) compute random offsets
4) add random offset to top left location coordinates to computer new random location withing given boundaries

________
# taken out of my old working code, modified to illustrate example with given data
import random
...
                # we know where top left corner is
                topleft = Location (744,1043)
                # 799 - 744 = 55 and we need random X offset
                x_offset = random.randint(0,55)
                # 1077 - 1043 = 34 and we need random Y offset
                y_offset = random.randint(0,34)
                click(topleft.right(x).below(y))

Can you help with this problem?

Provide an answer of your own, or ask Phil for more information if necessary.

To post a message you must log in.