Screen
Use Screen to access frame sizes and other screens on a multi-screen setup. Beware that a screen can get stale if you keep a reference to it and it is for instance disconnected while you do so.
Interface
class Screen implements Identifiable, Iterable
static Screen main()
static Array<Screen> all()
String identifier()
Rectangle frame()
Rectangle visibleFrame()
Rectangle flippedFrame()
Rectangle flippedVisibleFrame()
Space currentSpace() // macOS 10.11+
Array<Space> spaces() // macOS 10.11+
Array<Window> windows(Map<String, AnyObject> optionals)
end
Static Methods
main()
returns the screen containing the window with the keyboard focusall()
returns all screens, the first screen in this array corresponds to the primary screen for the system
Instance Methods
identifier()
returns the UUID for the screenframe()
returns the whole frame for the screen, bottom left based originvisibleFrame()
returns the visible frame for the screen subtracting the Dock and Menu from the frame when visible, bottom left based originflippedFrame()
returns the whole frame for the screen, top left based originflippedVisibleFrame()
returns the visible frame for the screen subtracting the Dock and Menu from the frame when visible, top left based origincurrentSpace()
returns the current space for the screen (macOS 10.11+, returnsundefined
otherwise)spaces()
returns all spaces for the screen (macOS 10.11+, returns an empty list otherwise)windows(Map<String, AnyObject> optionals)
returns all windows for the screen if no optionals are given
Optionals
visible
(boolean): if settrue
returns all visible windows for the screen, if setfalse
returns all hidden windows for the screen
Events
See Events for a list of available events for Screen.
Example
// Get all available screens
const screens = Screen.all();
// Get visible frame for the main screen
const frame = Screen.main().visibleFrame();
// Get all windows on the main screen
Screen.main().windows();
// Get all visible windows on the main screen
Screen.main().windows({ visible: true });