Select Region error

Asked by Deividas on 2018-01-18

CODE:
import random
def randomClick(region):
    clickX = random.randint(region.x, region.x + region.w)
    clickY = random.randint(region.y, region.y + region.h)
    click(Location(clickX, clickY))

image = Pattern("image.png").similar(0.85)
imageMap = selectRegion(Region(1627,856,247,149))

while true:
    if exists(image, 0):
        click(Pattern("image.png").similar(0.85))
        wait(1)
    else:
        randomClick(imageMap)
        wait(1)

Error is with selection region so I chose region and it's error called : TypeError: selectRegion(): 1st arg can't be coerced to String

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2018-01-18
Last reply:
2018-01-18
RaiMan (raimund-hocke) said : #1

as mentioned:
you have to learn some basic Python.

... and the docs show you how to use selectRegion:
http://sikulix-2014.readthedocs.io/en/latest/screen.html#Screen.selectRegion

correct:
imageMap = Region(1627,856,247,149)
(hope you used the Region select button in the IDE for that ;-)

or
imageMap = selectRegion() # to paint the region at each run

BTW:
click(Pattern("image.png").similar(0.85))

can be
click()

in this case, since you want to click the image, that was already found by
exists(image, 0)

this is a convenience feature (last match)

Can you help with this problem?

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

To post a message you must log in.