Class 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 Detail

      • ignorePrimaryAtCapture

        public static boolean ignorePrimaryAtCapture
    • Constructor Detail

      • 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
    • 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
        Specified by:
        isValid in interface org.sikuli.script.support.IScreen
        Overrides:
        isValid in class Region
        Returns:
        true if yes, false otherwise
      • isValidWithMessage

        public java.lang.String isValidWithMessage()
        Specified by:
        isValidWithMessage in interface org.sikuli.script.support.IScreen
      • getDeviceDescription

        public java.lang.String getDeviceDescription()
        Specified by:
        getDeviceDescription in interface org.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 interface org.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 interface org.sikuli.script.support.IScreen
      • getID

        public int getID()
        Specified by:
        getID in interface org.sikuli.script.support.IScreen
        Returns:
        the id
      • getIDString

        public java.lang.String getIDString()
        Specified by:
        getIDString in interface org.sikuli.script.support.IScreen
      • getIdFromPoint

        public int getIdFromPoint​(int x,
                                  int y)
        INTERNAL USE: to be compatible with ScreenUnion
        Specified by:
        getIdFromPoint in interface org.sikuli.script.support.IScreen
        Parameters:
        x - value
        y - value
        Returns:
        id of the screen
      • setOther

        public Region setOther​(Region element)
        Specified by:
        setOther in interface org.sikuli.script.support.IScreen
      • setOther

        public Location setOther​(Location element)
        Specified by:
        setOther in interface org.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 interface org.sikuli.script.support.IScreen
        Parameters:
        loc - Location
        width - value
        height - value
        Returns:
        the new region
      • newRegion

        public Region newRegion​(Region reg)
        Specified by:
        newRegion in interface org.sikuli.script.support.IScreen
      • newRegion

        public Region newRegion​(int x,
                                int y,
                                int w,
                                int h)
        Specified by:
        newRegion in interface org.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 interface org.sikuli.script.support.IScreen
        Parameters:
        loc - Location
        Returns:
        the new location
      • newLocation

        public Location newLocation​(int x,
                                    int y)
        Specified by:
        newLocation in interface org.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 interface org.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 interface org.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 interface org.sikuli.script.support.IScreen
        Parameters:
        x - x-coordinate of the region to be captured
        y - y-coordinate of the region to be captured
        w - width of the region to be captured
        h - 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 interface org.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 interface org.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 interface org.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