How do I make sikuli search only to the left of current mouse position?

Asked by April L on 2018-06-01

Hi. I have multiple images of the same symbol around a particular rectangle. I want sikuli to only search on it's left side for the next step. How can I proceed?

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
April L
Solved:
2018-06-04
Last query:
2018-06-04
Last reply:
2018-06-03
arminius (arminius75) said : #1

I'm new at this, so make sure your backed up before you try it, but I managed to get a square region to go left of the mouse location, you should be able to swap out the mouse location for near the right of whatever images your looking for.
You can adjust the shape of the region easily by changing the Xis,Yis, Wis,His.

    wait(2)
    ml = Env.getMouseLocation()
    Xis = ml.getX()
    print(Xis)
    new_Xis = Xis - 400
    print(new_Xis)
    Yis = ml.getY()
    print(Yis)
    new_Yis = Yis - 200
    print(new_Yis)
    Wis = 400
    His = 400
    print(new_Xis)
    print(new_Yis)
    print(Wis)
    print(His)
    Left_Region_of_mouse_location = Region(new_Xis,new_Yis,Wis,His)
    Left_Region_of_mouse_location.highlight(5)

masuo (masuo-ohara) said : #2

order to limit the scope of the search, set the Region where you want to search.
then use find feature.

use Env.getMouseLocation() to get the current location of the mouse cursor.
ml = Env.getMouseLocation()

use Region() to define region where you want to search.

rfull = Region(getBounds())
rleft = Region(0, 0, ml.getX(), rfull.getH())

rleft.find("image.png")

masuo (masuo-ohara) said : #3

Sorry I was wrong, I forgot SCREEN.

rfull = Region(SCREEN.getBounds())

RaiMan (raimund-hocke) said : #4

@masuo

rfull = Region(getBounds())

is ok and the same as
rfull = Region(SCREEN.getBounds())

because undotted methods are automatically bound to the SCREEN object.

April L (april96) said : #5

Thanks a lot everyone