New question #665546 on Sikuli:
https://answers.launchpad.net/sikuli/+question/665546

Hi! I'm new to Python (but not to coding) and there's something I'm trying to 
do but I'm not sure how to do it. 

I want to click an image that appears in the screen several times (not one 
after other, after clicking it one time it disappears and appears again after a 
while), but I don't want to click it always in the center, I want to click it 
each time in a random place inside the image. 

I've been messing with the Region class and the functions getTopLeft(), 
getBottonLeft() etc and the Random class of Python, I've changed my code a 
million times but I still can't figure it out. If you could help me it would be 
great. I've seen similar answers in the forum but I'm not sure how to implement 
them in my code. 

This is what I have:

import random
m = find(imageIwantToClick)
click(m.targetOffset(random.randint(m.getTopLeft(),m.getBottomLeft()),random.randint(m.getTopRight(),m.getBottomRight())))

And I get this error:
[error] Error caused by: Traceback (most recent call last): File 
"C:\Users\Penguin\Documents\Sikuli Pruebas.sikuli\Sikuli Pruebas.py", line 3, 
in <module> l = 
random.randint(m.getTopLeft(),m.getBottomLeft()),random.randint(m.getTopRight(),m.getBottomRight())
 File "C:\Users\Irene A\Desktop\Sikuli\sikulix.jar\Lib\random.py", line 241, in 
randint TypeError: unsupported operand type(s) for +: 
'org.sikuli.script.Location' and 'int' 


>From what I understand, I always have to introduce an image inside the 
>function click() to make it work? But then, I don't know how to click in a 
>place that isn't an image, just a coordinate in the screen.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to