Browse the docs

screenIndex

Returns a screen's position when the screens are counted from left to right.

Keyboard Maestro: SCREENINDEX

Details #

screenIndex(which?) takes zero or one argument and returns a 1-based number: the screen's place when all screens are ordered by their left edge. which picks the screen the same way as in screen: empty or main for the main screen, a 1-based number, last, or all or part of a name.

The main screen is 2 if one other screen sits to its left.

Parameters #

Takes 0 to 1 argument. {{ screenIndex(text?) }}

Examples #

screenCount() > 0 ? screenIndex() : 0
→ 0
screenCount() > 0 ? screenIndex("last") : 0
→ 0

Gotchas #

  • A screen that doesn't exist is an error: screenIndex() found no screen 'Studio'. With no screens to read (a test run, a fake system) it always is, so check screenCount() first.