Package org.sikuli.script
Class Screen
- java.lang.Object
-
- org.sikuli.script.Element
-
- org.sikuli.script.Region
-
- org.sikuli.script.Screen
-
- All Implemented Interfaces:
org.sikuli.script.support.IScreen
public class Screen extends Region implements org.sikuli.script.support.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.
-
-
Field Summary
Fields Modifier and Type Field Description static booleanignorePrimaryAtCaptureScreenImagelastScreenImage-
Fields 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, 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, WS
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static org.sikuli.script.support.ScreenUnionall()create a Screen (ScreenUnion) object as a united region of all available monitorsScreenImagecapture()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(java.awt.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(java.lang.Object... args)static voiddoPrompt(java.lang.String message, org.sikuli.util.EventObserver obs)static Screenget(int id)java.awt.RectanglegetBounds()static java.awt.RectanglegetBounds(int id)static ScreengetDefaultInstance4py()java.lang.StringgetDeviceDescription()intgetID()intgetIdFromPoint(int x, int y)INTERNAL USE: to be compatible with ScreenUnionjava.lang.StringgetIDString()ScreenImagegetLastScreenImageFromScreen()intgetMonitor()static java.awt.RectanglegetMonitorBounds()static java.awt.RectanglegetMonitorBounds(int n)static intgetMonitorCount()static org.sikuli.script.support.IRobotgetMonitorRobot(int n)static intgetNumberScreens()static ScreengetPrimaryScreen()org.sikuli.script.support.IRobotgetRobot()Gets the Robot of this Screen.intgetScale()static intgetScaleFactor(int x, int y)static ScreengetScreen(int id)static intgetScreenMonitor(int n)booleanhasPrompt()static booleanisHeadless()booleanisValid()Check whether this Region is contained by any of the available screensjava.lang.StringisValidWithMessage()static Screenmake4py(java.util.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()static voidresetMonitorsQuiet()static voidresetPrompt(org.sikuli.util.OverlayCapturePrompt ocp)RegionselectRegion()interactive region create with predefined message: lets the user draw the rectangle using the mouseRegionselectRegion(java.lang.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 sensevoidsetMonitor(int monitor)LocationsetOther(Location element)RegionsetOther(Region element)static 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(java.lang.String message)interactive capture with given message: lets the user capture a screen image using the mouse to draw the rectangle-
Methods 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, bottom, bottomLeft, bottomMiddle, bottomRight, contains, contains, containsMouse, copyTo, copyTo, create, create, create, create, create, create, delayType, doubleClick, doubleClick, doubleClick, drag, dragDrop, dragDrop, dropAt, exists, existsText, existsText, find, findAll, findAllList, findAllText, findAny, findAnyList, findText, getBottomLeft, getBottomRight, getCell, getCol, getCol, getCols, getColW, getContent, getEvent, getEvents, getImage, getInset, getLastScreenImage, getLastScreenImageFile, getLastScreenImageFile, getLastScreenImageFile, getObserver, getROI, getRow, getRow, getRowH, getRows, getScreenContaining, getTile, getTopLeft, getTopRight, grow, grow, grow, grow, grow, grow, grow, hasEvents, hasObserver, hasText, highlight, highlight, highlight, highlight, highlight4py, highlightAllOff, highlightOff, highlightOn, highlightOn, inside, internalUseOnlyHighlightReset, isObserving, isRasterValid, keyDown, keyDown, keyUp, keyUp, keyUp, left, left, leftAt, leftAt, leftMiddle, leftSide, middle, morphTo, moveTo, nearby, nearby, observe, observe, observeInBackground, observeInBackground, observeInLine, offset, offset, onAppear, onAppear, onChange, onChange, onChange, onChange, onChangeDo, onVanish, onVanish, paste, paste, right, right, rightAt, rightAt, rightClick, rightClick, rightClick, rightMiddle, rightSide, saveCapture, saveLastScreenImage, setActive, setBottomLeft, setBottomRight, setCols, setInactive, setLocation, setRaster, setROI, setROI, setROI, setROI, setRows, setSize, setTopLeft, setTopRight, stopObserver, stopObserver, top, topLeft, topMiddle, topRight, toString, toStringShort, type, type, type, type, type, type, wait, waitT, waitT, waitText, waitText, waitVanish, wheel, wheel, wheel, wheel, wheel, wheel, wheel, wheel, wheel, wheel, write
-
Methods inherited from class org.sikuli.script.Element
asFakeImage, asMaskImage, asText, black, black, cacheStats, click, click, click, cloneContent, collectLines, collectLinesText, collectWords, collectWordsText, createURL, createURL, delayClick, diffPercentage, exists, existsT, file, fileName, findAllByColumn, findAllByRow, findAllT, findBest, findBestList, findChanges, findLine, findLines, findLines, findT, findWord, findWords, findWords, getAll, getAutoWaitTimeout, getBufferedImage, getBufferedImage, getCache, getCenter, getFindFailedHandler, getFindFailedResponse, getH, getImage, getLastMatch, getLastMatches, getMatchLastSeen, getName, getObserveScanRate, getOtherScreen, getPoint, getRect, getRepeatWaitTime, getScreen, getSize, getTarget, getThrowException, getValidImageFilename, getW, getWaitScanRate, getX, getY, has, has, hasT, hasURL, hover, hover, ignoreLastSeen, initScreen, intersection, isFakeImage, isInside, isMaskImage, isOtherScreen, isText, isVirtual, match, match, matches, matches, mean, meanColor, mouseDown, mouseMove, mouseMove, mouseMove, mouseUp, mouseUp, plain, plain, reload, reload, reLocate, resetCache, resetFindFailedResponse, resetThrowException, resize, resize, sameSize, save, save, save, set, set, setAutoWaitTimeout, setCenter, setContent, setFindFailedHandler, setFindFailedResponse, setH, setLocation, setMissingAbort, setMissingPrompt, setName, setObserveScanRate, setOtherScreen, setRect, setRect, setRect, setRepeatWaitTime, setScreen, setThrowException, setVirtual, setW, setWaitScanRate, setX, setX, setY, setY, size, size, stdDev, text, textChar, textLine, textLines, textWord, textWords, traceOff, traceOn, union, unionAll, unionAny, unionAnyList, updateContent, url, url, url, virtual, wait, wait, waitVanish, white
-
-
-
-
Field Detail
-
ignorePrimaryAtCapture
public static boolean ignorePrimaryAtCapture
-
lastScreenImage
public ScreenImage lastScreenImage
-
-
Method Detail
-
getDefaultInstance4py
public static Screen getDefaultInstance4py()
-
make4py
public static Screen make4py(java.util.ArrayList args)
-
isValid
public boolean isValid()
Description copied from class:RegionCheck whether this Region is contained by any of the available screens
-
isValidWithMessage
public java.lang.String isValidWithMessage()
- Specified by:
isValidWithMessagein interfaceorg.sikuli.script.support.IScreen
-
getDeviceDescription
public java.lang.String getDeviceDescription()
- Specified by:
getDeviceDescriptionin interfaceorg.sikuli.script.support.IScreen
-
get
public static Screen get(int id)
-
getNumberScreens
public static int getNumberScreens()
- Returns:
- number of available screens
-
getPrimaryScreen
public static Screen getPrimaryScreen()
- Returns:
- the screen at (0,0), if not exists the one with id 0
-
getScreen
public static Screen getScreen(int id)
- Parameters:
id- of the screen- Returns:
- the screen with given id, the primary screen if id is invalid
-
getScale
public int getScale()
-
getBounds
public java.awt.Rectangle getBounds()
- Specified by:
getBoundsin interfaceorg.sikuli.script.support.IScreen- Returns:
- the screen's rectangle
-
getBounds
public static java.awt.Rectangle getBounds(int id)
- Parameters:
id- of the screen- Returns:
- the physical coordinate/size
as AWT.Rectangle to avoid mix up with getROI
-
getLastScreenImageFromScreen
public ScreenImage getLastScreenImageFromScreen()
- Specified by:
getLastScreenImageFromScreenin interfaceorg.sikuli.script.support.IScreen
-
getID
public int getID()
- Specified by:
getIDin interfaceorg.sikuli.script.support.IScreen- Returns:
- the id
-
getIDString
public java.lang.String getIDString()
- Specified by:
getIDStringin interfaceorg.sikuli.script.support.IScreen
-
getIdFromPoint
public int getIdFromPoint(int x, int y)INTERNAL USE: to be compatible with ScreenUnion- Specified by:
getIdFromPointin interfaceorg.sikuli.script.support.IScreen- Parameters:
x- valuey- value- Returns:
- id of the screen
-
setOther
public Region setOther(Region element)
- Specified by:
setOtherin interfaceorg.sikuli.script.support.IScreen
-
setOther
public Location setOther(Location element)
- Specified by:
setOtherin interfaceorg.sikuli.script.support.IScreen
-
newRegion
public Region newRegion(Location loc, int width, int height)
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.- Specified by:
newRegionin interfaceorg.sikuli.script.support.IScreen- Parameters:
loc- Locationwidth- valueheight- value- Returns:
- the new region
-
newRegion
public Region newRegion(Region reg)
- Specified by:
newRegionin interfaceorg.sikuli.script.support.IScreen
-
newRegion
public Region newRegion(int x, int y, int w, int h)
- Specified by:
newRegionin interfaceorg.sikuli.script.support.IScreen
-
newLocation
public Location newLocation(Location loc)
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 interfaceorg.sikuli.script.support.IScreen- Parameters:
loc- Location- Returns:
- the new location
-
newLocation
public Location newLocation(int x, int y)
- Specified by:
newLocationin interfaceorg.sikuli.script.support.IScreen
-
all
public static org.sikuli.script.support.ScreenUnion 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
-
getMonitor
public int getMonitor()
-
setMonitor
public void setMonitor(int monitor)
-
isHeadless
public static boolean isHeadless()
-
getMonitorCount
public static int getMonitorCount()
-
getMonitorBounds
public static java.awt.Rectangle getMonitorBounds()
-
getMonitorBounds
public static java.awt.Rectangle getMonitorBounds(int n)
-
getMonitorRobot
public static org.sikuli.script.support.IRobot getMonitorRobot(int n)
-
getScreenMonitor
public static int getScreenMonitor(int n)
-
showMonitors
public static void showMonitors()
show the current monitor setup
-
resetMonitors
public static void resetMonitors()
-
resetMonitorsQuiet
public static void resetMonitorsQuiet()
-
getScaleFactor
public static int getScaleFactor(int x, int y)
-
getRobot
public org.sikuli.script.support.IRobot getRobot()
Gets the Robot of this Screen.- Specified by:
getRobotin interfaceorg.sikuli.script.support.IScreen- Returns:
- The Robot for this Screen
-
cmdCapture
public ScreenImage cmdCapture(java.lang.Object... args)
-
capture
public ScreenImage capture()
create a ScreenImage with the physical bounds of this screen- Specified by:
capturein interfaceorg.sikuli.script.support.IScreen- Returns:
- the image
-
capture
public ScreenImage capture(int x, int y, int w, int h)
create a ScreenImage with given coordinates on this screen.- Specified by:
capturein interfaceorg.sikuli.script.support.IScreen- Parameters:
x- x-coordinate of the region to be capturedy- y-coordinate of the region to be capturedw- width of the region to be capturedh- height of the region to be captured- Returns:
- the image of the region
-
capture
public ScreenImage capture(java.awt.Rectangle rect)
create a ScreenImage with given rectangle on this screen.- Specified by:
capturein interfaceorg.sikuli.script.support.IScreen- Parameters:
rect- The Rectangle to be captured- Returns:
- the image of the region
-
capture
public ScreenImage capture(Region reg)
create a ScreenImage with given region on this screen- Specified by:
capturein interfaceorg.sikuli.script.support.IScreen- Parameters:
reg- The Region to be captured- Returns:
- the image of the region
-
doPrompt
public static void doPrompt(java.lang.String message, org.sikuli.util.EventObserver obs)
-
closePrompt
public static void closePrompt()
-
closePrompt
public static void closePrompt(Screen scr)
-
resetPrompt
public static void resetPrompt(org.sikuli.util.OverlayCapturePrompt ocp)
-
hasPrompt
public boolean hasPrompt()
-
userCapture
public ScreenImage userCapture()
interactive capture with predefined message: lets the user capture a screen image using the mouse to draw the rectangle- Returns:
- the image
-
userCapture
public ScreenImage userCapture(java.lang.String message)
interactive capture with given message: lets the user capture a screen image using the mouse to draw the rectangle- Specified by:
userCapturein interfaceorg.sikuli.script.support.IScreen- Parameters:
message- text- Returns:
- the image
-
selectRegion
public Region selectRegion()
interactive region create with predefined message: lets the user draw the rectangle using the mouse- Returns:
- the region
-
selectRegion
public Region selectRegion(java.lang.String message)
interactive region create with given message: lets the user draw the rectangle using the mouse- Parameters:
message- text- Returns:
- the region
-
-