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 boolean
ignorePrimaryAtCapture
ScreenImage
lastScreenImage
-
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.ScreenUnion
all()
create a Screen (ScreenUnion) object as a united region of all available monitorsScreenImage
capture()
create a ScreenImage with the physical bounds of this screenScreenImage
capture(int x, int y, int w, int h)
create a ScreenImage with given coordinates on this screen.ScreenImage
capture(java.awt.Rectangle rect)
create a ScreenImage with given rectangle on this screen.ScreenImage
capture(Region reg)
create a ScreenImage with given region on this screenstatic void
closePrompt()
static void
closePrompt(Screen scr)
ScreenImage
cmdCapture(java.lang.Object... args)
static void
doPrompt(java.lang.String message, org.sikuli.util.EventObserver obs)
static Screen
get(int id)
java.awt.Rectangle
getBounds()
static java.awt.Rectangle
getBounds(int id)
static Screen
getDefaultInstance4py()
java.lang.String
getDeviceDescription()
int
getID()
int
getIdFromPoint(int x, int y)
INTERNAL USE: to be compatible with ScreenUnionjava.lang.String
getIDString()
ScreenImage
getLastScreenImageFromScreen()
int
getMonitor()
static java.awt.Rectangle
getMonitorBounds()
static java.awt.Rectangle
getMonitorBounds(int n)
static int
getMonitorCount()
static org.sikuli.script.support.IRobot
getMonitorRobot(int n)
static int
getNumberScreens()
static Screen
getPrimaryScreen()
org.sikuli.script.support.IRobot
getRobot()
Gets the Robot of this Screen.int
getScale()
static int
getScaleFactor(int x, int y)
static Screen
getScreen(int id)
static int
getScreenMonitor(int n)
boolean
hasPrompt()
static boolean
isHeadless()
boolean
isValid()
Check whether this Region is contained by any of the available screensjava.lang.String
isValidWithMessage()
static Screen
make4py(java.util.ArrayList args)
Location
newLocation(int x, int y)
Location
newLocation(Location loc)
creates a location on the current screen with the given point.Region
newRegion(int x, int y, int w, int h)
Region
newRegion(Location loc, int width, int height)
creates a region on the current screen with the given coordinate/size.Region
newRegion(Region reg)
static void
resetMonitors()
static void
resetMonitorsQuiet()
static void
resetPrompt(org.sikuli.util.OverlayCapturePrompt ocp)
Region
selectRegion()
interactive region create with predefined message: lets the user draw the rectangle using the mouseRegion
selectRegion(java.lang.String message)
interactive region create with given message: lets the user draw the rectangle using the mousevoid
setAsScreen()
INTERNAL USE reset from being a screen union to the screen used beforevoid
setAsScreenUnion()
INTERNAL USE collect all physical screens to one big region
This is under evaluation, wether it really makes sensevoid
setMonitor(int monitor)
Location
setOther(Location element)
Region
setOther(Region element)
static void
showMonitors()
show the current monitor setupScreenImage
userCapture()
interactive capture with predefined message: lets the user capture a screen image using the mouse to draw the rectangleScreenImage
userCapture(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:Region
Check whether this Region is contained by any of the available screens
-
isValidWithMessage
public java.lang.String isValidWithMessage()
- Specified by:
isValidWithMessage
in interfaceorg.sikuli.script.support.IScreen
-
getDeviceDescription
public java.lang.String getDeviceDescription()
- Specified by:
getDeviceDescription
in 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:
getBounds
in 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:
getLastScreenImageFromScreen
in interfaceorg.sikuli.script.support.IScreen
-
getID
public int getID()
- Specified by:
getID
in interfaceorg.sikuli.script.support.IScreen
- Returns:
- the id
-
getIDString
public java.lang.String getIDString()
- Specified by:
getIDString
in interfaceorg.sikuli.script.support.IScreen
-
getIdFromPoint
public int getIdFromPoint(int x, int y)
INTERNAL USE: to be compatible with ScreenUnion- Specified by:
getIdFromPoint
in interfaceorg.sikuli.script.support.IScreen
- Parameters:
x
- valuey
- value- Returns:
- id of the screen
-
setOther
public Region setOther(Region element)
- Specified by:
setOther
in interfaceorg.sikuli.script.support.IScreen
-
setOther
public Location setOther(Location element)
- Specified by:
setOther
in 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:
newRegion
in interfaceorg.sikuli.script.support.IScreen
- Parameters:
loc
- Locationwidth
- valueheight
- value- Returns:
- the new region
-
newRegion
public Region newRegion(Region reg)
- Specified by:
newRegion
in interfaceorg.sikuli.script.support.IScreen
-
newRegion
public Region newRegion(int x, int y, int w, int h)
- Specified by:
newRegion
in 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:
newLocation
in interfaceorg.sikuli.script.support.IScreen
- Parameters:
loc
- Location- Returns:
- the new location
-
newLocation
public Location newLocation(int x, int y)
- Specified by:
newLocation
in 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:
getRobot
in 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:
capture
in 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:
capture
in 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:
capture
in 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:
capture
in 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:
userCapture
in 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
-
-