Package org.sikuli.script
Class Screen
java.lang.Object
org.sikuli.script.Element
org.sikuli.script.Region
org.sikuli.script.Screen
- All Implemented Interfaces:
IScreen
- Direct Known Subclasses:
ScreenUnion
public class Screen extends Region implements IScreen
A screen represents a physical monitor with its coordinates and size according to the global
point system: the screen areas are grouped around a point (0,0) like in a cartesian system (the
top left corner and the points contained in the screen area might have negative x and/or y values)
The screens are arranged in an array (index = id) and each screen is always the same object (not possible to create new objects).
A screen inherits from class Region, so it can be used as such in all aspects. If you need the region of the screen more than once, you have to create new ones based on the screen.
The so called primary screen is the one with top left (0,0) and has id 0.
The screens are arranged in an array (index = id) and each screen is always the same object (not possible to create new objects).
A screen inherits from class Region, so it can be used as such in all aspects. If you need the region of the screen more than once, you have to create new ones based on the screen.
The so called primary screen is the one with top left (0,0) and has id 0.
-
Field Summary
Fields Modifier and Type Field Description protected intcurIDstatic booleanignorePrimaryAtCaptureScreenImagelastScreenImageprotected static StringlogNameprotected intmonitorprotected intoldIDprotected static intprimaryScreenprotected OverlayCapturePromptpromptprotected static Screen[]screensprotected booleanwaitPromptFields inherited from class org.sikuli.script.Region
BB, BH, BL, BM, BOTTOM, BR, C2, CH, CV, EAST, EAST_MID, EAST_NORTH, EAST_SOUTH, EH, EM, EN, ES, LB, LEFT, LH, LL, LM, LT, M2, M3, MH, MID_HORIZONTAL, MID_VERTICAL, MIDDLE, MIDDLE_BIG, MM, MV, NE, NH, NM, NORTH, NORTH_EAST, NORTH_MID, NORTH_WEST, NW, otherScreen, RB, RH, RIGHT, RM, RR, RT, SE, SH, SM, SOUTH, SOUTH_EAST, SOUTH_MID, SOUTH_WEST, SW, TH, TL, TM, TOP, TR, TT, WEST, WEST_MID, WEST_NORTH, WEST_SOUTH, WH, WM, WN, WSFields inherited from class org.sikuli.script.Element
h, imageMissingHandler, lastFindTime, lastMatch, lastMatches, lastSearchTime, lastSearchTimeRepeat, logLevel, w, x, y -
Constructor Summary
-
Method Summary
Modifier and Type Method Description static ScreenUnionall()create a Screen (ScreenUnion) object as a united region of all available monitorsstatic Screenas(int id)ScreenImagecapture()create a ScreenImage with the physical bounds of this screenScreenImagecapture(int x, int y, int w, int h)create a ScreenImage with given coordinates on this screen.ScreenImagecapture(Rectangle rect)create a ScreenImage with given rectangle on this screen.ScreenImagecapture(Region reg)create a ScreenImage with given region on this screenstatic voidclosePrompt()static voidclosePrompt(Screen scr)ScreenImagecmdCapture(Object... args)static voiddoPrompt(String message, EventObserver obs)RectanglegetBounds()static RectanglegetBounds(int id)static ScreengetDefaultInstance4py()protected static IRobotgetGlobalRobot()intgetID()intgetIdFromPoint(int x, int y)INTERNAL USE: to be compatible with ScreenUnionStringgetIDString()ScreenImagegetLastScreenImageFromScreen()static RectanglegetMonitor(int n)static intgetNumberScreens()static intgetPrimaryId()static ScreengetPrimaryScreen()IRobotgetRobot()Gets the Robot of this Screen.static IRobotgetRobot(int id)each screen has exactly one robot (internally used for screen capturing)
available as a convenience for those who know what they are doing.protected static IRobotgetRobot(Region reg)ScreengetScreen()static ScreengetScreen(int id)static RectanglehasPoint(Point aPoint)booleanhasPrompt()protected static voidinitScreens(boolean reset)static booleanisHeadless()static Screenmake4py(ArrayList args)LocationnewLocation(int x, int y)LocationnewLocation(Location loc)creates a location on the current screen with the given point.RegionnewRegion(int x, int y, int w, int h)RegionnewRegion(Location loc, int width, int height)creates a region on the current screen with the given coordinate/size.RegionnewRegion(Region reg)static voidresetMonitors()re-initialize the monitor setup (e.g. when it was changed while running)static voidresetMonitorsQuiet()static voidresetPrompt(OverlayCapturePrompt ocp)RegionselectRegion()interactive region create with predefined message: lets the user draw the rectangle using the mouseRegionselectRegion(String message)interactive region create with given message: lets the user draw the rectangle using the mousevoidsetAsScreen()INTERNAL USE reset from being a screen union to the screen used beforevoidsetAsScreenUnion()INTERNAL USE collect all physical screens to one big region
This is under evaluation, wether it really makes senseLocationsetOther(Location element)RegionsetOther(Region element)protected RegionsetScreen(IScreen s)Should not be used - makes no sense for Screen objectstatic voidshowMonitors()show the current monitor setupScreenImageuserCapture()interactive capture with predefined message: lets the user capture a screen image using the mouse to draw the rectangleScreenImageuserCapture(String message)interactive capture with given message: lets the user capture a screen image using the mouse to draw the rectangleMethods inherited from class org.sikuli.script.Region
above, above, aboveAt, aboveAt, add, add, add, aInput, aKey, asOffset, aSwipe, aSwipeDown, aSwipeLeft, aSwipeRight, aSwipeUp, aTap, atMouse, below, below, belowAt, belowAt, checkMatch, click, click, click, contains, contains, containsMouse, copyTo, copyTo, create, create, create, create, create, create, create, delayClick, delayType, doHighlight, doubleClick, doubleClick, doubleClick, drag, dragDrop, dragDrop, dropAt, exists, exists, existsText, existsText, find, findAll, findAllByColumn, findAllByRow, findAllList, findAllText, findAny, findAnyList, findBest, findBestList, findText, get, getAll, getAutoWaitTimeout, getBottomLeft, getBottomRight, getCell, getCenter, getCol, getCol, getCols, getColW, getEvent, getEvents, getFakeRegion, getFindFailedResponse, getImage, getInset, getLastScreenImage, getLastScreenImageFile, getLastScreenImageFile, getLastScreenImageFile, getLocationFromTarget, getObserver, getObserveScanRate, getRect, getRectangle, getRepeatWaitTime, getROI, getRow, getRow, getRowH, getRows, getScreenContaining, getTarget, getThrowException, getTopLeft, getTopRight, getWaitScanRate, grow, grow, grow, grow, grow, grow, grow, has, has, hasEvents, hasObserver, hasText, highlight, highlight, highlight, highlight, highlight4py, highlightAllOff, highlightOff, highlightOn, highlightOn, hover, hover, initScreen, inside, internalUseOnlyHighlightReset, intersection, isObserving, isOtherScreen, isRasterValid, isValid, isVirtual, keyDown, keyDown, keyUp, keyUp, keyUp, left, left, leftAt, leftAt, morphTo, mouseDown, mouseMove, mouseMove, mouseMove, mouseUp, mouseUp, moveTo, nearby, nearby, observe, observe, observeInBackground, observeInBackground, observeInLine, offset, offset, onAppear, onAppear, onChange, onChange, onChange, onChange, onChangeDo, onVanish, onVanish, paste, paste, regionOnScreen, relocate, relocate, resetFindFailedResponse, resetScreens, resetThrowException, right, right, rightAt, rightAt, rightClick, rightClick, rightClick, saveCapture, saveLastScreenImage, setActive, setAutoWaitTimeout, setBottomLeft, setBottomRight, setCenter, setCols, setFindFailedHandler, setFindFailedResponse, setH, setInactive, setLocation, setObserveScanRate, setOtherScreen, setOtherScreen, setRaster, setRect, setRect, setRect, setRepeatWaitTime, setROI, setROI, setROI, setROI, setRows, setScreen, setSize, setThrowException, setTopLeft, setTopRight, setVirtual, setW, setWaitScanRate, setX, setY, showScreens, stopObserver, stopObserver, toGlobalCoord, toString, toStringShort, type, type, type, type, type, type, union, unionAll, unionAny, unionAnyList, virtual, wait, wait, wait, waitT, waitT, waitText, waitText, waitVanish, waitVanish, wheel, wheel, wheel, writeMethods inherited from class org.sikuli.script.Element
collectLines, collectLinesText, collectWords, collectWordsText, existsT, findAllT, findLine, findLines, findLines, findT, findWord, findWords, findWords, getBufferedImage, getH, getImageFromTarget, getLastMatch, getLastMatches, getName, getW, getX, getY, hasT, isEmpty, log, returnThis, setImageMissingHandler, setName, text, textChar, textLine, textLines, textWord, textWordsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.sikuli.script.support.IScreen
getH, getLastScreenImageFile, getRect, getW, getX, getY, isOtherScreen
-
Field Details
-
logName
- See Also:
- Constant Field Values
-
screens
-
primaryScreen
protected static int primaryScreen -
curID
protected int curID -
oldID
protected int oldID -
monitor
protected int monitor -
waitPrompt
protected boolean waitPrompt -
prompt
-
ignorePrimaryAtCapture
public static boolean ignorePrimaryAtCapture -
lastScreenImage
-
-
Constructor Details
-
Screen
public Screen()Is the screen object having the top left corner as (0,0). If such a screen does not exist it is the screen with id 0. -
Screen
public Screen(int id)The screen object with the given id- Parameters:
id- valid screen number
-
Screen
public Screen(boolean isScreenUnion)INTERNAL USE collect all physical screens to one big region
TODO: under evaluation, wether it really makes sense- Parameters:
isScreenUnion- true/false
-
-
Method Details
-
getDefaultInstance4py
-
isHeadless
public static boolean isHeadless() -
getMonitor
-
hasPoint
-
initScreens
protected static void initScreens(boolean reset) -
make4py
-
as
-
getGlobalRobot
-
all
create a Screen (ScreenUnion) object as a united region of all available monitors- Returns:
- ScreenUnion
-
setAsScreenUnion
public void setAsScreenUnion()INTERNAL USE collect all physical screens to one big region
This is under evaluation, wether it really makes sense -
setAsScreen
public void setAsScreen()INTERNAL USE reset from being a screen union to the screen used before -
getScreen
-
setScreen
Should not be used - makes no sense for Screen object -
showMonitors
public static void showMonitors()show the current monitor setup -
resetMonitors
public static void resetMonitors()re-initialize the monitor setup (e.g. when it was changed while running) -
resetMonitorsQuiet
public static void resetMonitorsQuiet() -
getNumberScreens
public static int getNumberScreens()- Returns:
- number of available screens
-
getPrimaryId
public static int getPrimaryId()- Returns:
- the id of the screen at (0,0), if not exists 0
-
getPrimaryScreen
- Returns:
- the screen at (0,0), if not exists the one with id 0
-
getScreen
- Parameters:
id- of the screen- Returns:
- the screen with given id, the primary screen if id is invalid
-
getBounds
-
getBounds
- Parameters:
id- of the screen- Returns:
- the physical coordinate/size
as AWT.Rectangle to avoid mix up with getROI
-
getRobot
each screen has exactly one robot (internally used for screen capturing)
available as a convenience for those who know what they are doing. Should not be needed normally.- Parameters:
id- of the screen- Returns:
- the AWT.Robot of the given screen, if id invalid the primary screen
-
getID
public int getID() -
getIDString
- Specified by:
getIDStringin interfaceIScreen
-
getIdFromPoint
public int getIdFromPoint(int x, int y)INTERNAL USE: to be compatible with ScreenUnion- Specified by:
getIdFromPointin interfaceIScreen- Parameters:
x- valuey- value- Returns:
- id of the screen
-
getRobot
Gets the Robot of this Screen. -
getRobot
-
newRegion
creates a region on the current screen with the given coordinate/size. The coordinate is translated to the current screen from its relative position on the screen it would have been created normally. -
newRegion
-
newRegion
-
newLocation
creates a location on the current screen with the given point. The coordinate is translated to the current screen from its relative position on the screen it would have been created normally.- Specified by:
newLocationin interfaceIScreen- Parameters:
loc- Location- Returns:
- the new location
-
getLastScreenImageFromScreen
- Specified by:
getLastScreenImageFromScreenin interfaceIScreen
-
cmdCapture
-
capture
create a ScreenImage with the physical bounds of this screen -
capture
create a ScreenImage with given coordinates on this screen. -
capture
create a ScreenImage with given rectangle on this screen. -
capture
create a ScreenImage with given region on this screen -
doPrompt
-
closePrompt
public static void closePrompt() -
closePrompt
-
resetPrompt
-
hasPrompt
public boolean hasPrompt() -
userCapture
interactive capture with predefined message: lets the user capture a screen image using the mouse to draw the rectangle- Returns:
- the image
-
userCapture
interactive capture with given message: lets the user capture a screen image using the mouse to draw the rectangle- Specified by:
userCapturein interfaceIScreen- Parameters:
message- text- Returns:
- the image
-
selectRegion
interactive region create with predefined message: lets the user draw the rectangle using the mouse- Returns:
- the region
-
selectRegion
interactive region create with given message: lets the user draw the rectangle using the mouse- Parameters:
message- text- Returns:
- the region
-
setOther
-
setOther
-
newLocation
- Specified by:
newLocationin interfaceIScreen
-