Getting a sub region from a region.

Asked by Shienarier

Is there a way to get a region using coordinates in the context of another region?
I for example want the Region(50, 50, 50, 50) of an app.

I have tried things like this:
app = App("Firefox")
region = app.window()
subregion = Region(50, 50, 50, 50)
region.getRegionFromPSRM(subregion)

That is I want the region at 50, 50 in the Firefox window, not in my monitor in general.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Shienarier
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

I posted a request bug 702291 for this missing function. Pls. go there and register yourself as affected to boost it up.

Currenttly you have to make your own function (solution see bug) or region calculation.

your case:

reg = app.window()
sub = Region(reg.x+50, reg.y+50, 50, 50)

or:

reg = app.window()
sub = reg.offset(Location(50,50)); sub.setW=50; sub.setH=50

Revision history for this message
Shienarier (shienarier) said :
#2

Thank you.

I ended up writing this:
def get_subregion(reg, insidex, insidey, insidewidth, insideheight):
    return Region(reg.x+insidex, reg.y+insidey, insidewidth, insideheight)