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.centeris the horizontal middle andmiddlethe vertical middle. Short forms such asx,y,w,h,minX,maxYalso work, and case doesn't matter.which picks the screen:
mainor empty text for the main screen, a 1-based number (1is the main screen,2the 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, andscreen("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") : 00screenCount() > 0 ? screen("main", "center") : 00screenCount() > 0 ? screen("left", 25) : 00Gotchas #
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.