Browse the docs

screen

Returns a coordinate or size of a screen, in screen points.

Keyboard Maestro: SCREEN

Details #

screen(coordinate, percent?) or screen(which, coordinate, percent?) takes one to three arguments and returns a whole number.

  • coordinate is one of left, right, top, bottom, width, height, center, middle. center is the horizontal middle and middle the vertical middle. Short forms such as x, y, w, h, minX, maxY also work, and case doesn't matter.

  • which picks the screen: main or empty text for the main screen, a 1-based number (1 is the main screen, 2 the next), last, or all or part of a screen's name. With no which, the main screen is used.

  • percent gives the point that far along the screen instead: screen("width", 50) is half the screen's width, and screen("left", 25) is a quarter of the way across. Vertical coordinates go down from the top.

The origin is the top left of the main display. Use screenVisible for the area without the menu bar and Dock.

Parameters #

Takes 1 to 3 arguments. {{ screen(text, b?, c?) }}

Examples #

screenCount() > 0 ? screen("width") : 0
→ 0
screenCount() > 0 ? screen("main", "center") : 0
→ 0
screenCount() > 0 ? screen("left", 25) : 0
→ 0

Gotchas #

  • A screen that doesn't exist is an error: screen() found no screen 'Studio' (1 connected).

  • An unknown coordinate is an error: screen() doesn't know the coordinate 'size' (use left, right, top, bottom, width, height, center, middle).

  • The call needs at least one argument: screen() takes 1 to 3 arguments, got 0.

  • When there are no screens to read (a test run, a fake system) every call is the no-screen error. Check screenCount() first.