sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #06798
Re: [Question #178288]: How to get the screen zone (using Java) e.g top left zone, top right zone, ...etc
Question #178288 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/178288
Status: Open => Answered
RaiMan proposed the following answer:
Supposing, aScreen and lRegion are already defined.
final int SCREEN_HEIGHT = aScreen.h;
final int SCREEN_WIDTH = aScreen.w;
// to be multi monitor aware
final int SCREEN_X = aScreen.x;
final int SCREEN_Y = aScreen.y;
switch(lScreenZone)
{
case TOP_LEFT :
lRegion = Region.create(SCREEN_X, SCREEN_Y, SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
break;
case TOP_RIGHT :
lRegion = Region.create(SCREEN_X+SCREEN_WIDTH/2, SCREEN_Y, SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
break;
case BOTTOM_RIGHT :
lRegion = Region.create(SCREEN_X+SCREEN_WIDTH/2, SCREEN_Y+SCREEN_HEIGHT/2, SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
break;
case BOTTOM_LEFT :
lRegion = Region.create(SCREEN_X, SCREEN_Y+SCREEN_HEIGHT/2, SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
break;
case CENTER :
lRegion = Region.create(SCREEN_X+SCREEN_WIDTH/4, SCREEN_Y+SCREEN_HEIGHT/4, SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
break;
}
No need to use Rectangle. The Javadocs say use Region.create() (static
method).
... and yes, with Sikuli (x, y) is the upper left corner. and width /
height is w / h.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.