Get Index to Front Screen [Sub-Macro]

Use Case

  • Sometimes you need to know the Index Number of the FrontMost Active Screen in order to position windows on another screen.
  • Call this Sub-Macro to get this Index Number
    • The result is returned in KM Variable Instance__FrontScreenIndex
  • For Example: I want to position a window on the opposite screen of a two-screen system:
Execute Macro "Get Index to Front Screen [Sub-Macro]"
IF Instance__FrontScreenIndex = 1;
   THEN Move a Window to Screen 2;
ELSE Move a Window to Screen 1;
END

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MACRO:   Get Index to Front Screen [Sub-Macro]

-~~~ VER: 1.0    2020-08-16 ~~~
Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

DOWNLOAD Macro File:

Get Index to Front Screen [Sub-Macro].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


ReleaseNotes

Author.@JMichaelTX

PURPOSE:

  • Get Index to Front Screen

HOW TO USE

  1. First, make sure you have followed instructions in the Macro Setup below.
  2. Call this Sub-Macro using an Execute Macro Action.
  3. Front Screen Index is Returned in Instance__FrontScreenIndex

MACRO SETUP

  • Carefully review the Release Notes and the Macro Actions
    • Make sure you understand what the Macro will do.
    • You are responsible for running the Macro, not me. ??
      ..
      Make These Changes to this Macro
  1. Move this macro to a Macro Group that is only Active when you need this Macro.
  2. ENABLE this Macro, and the Macro Group it is in.

REQUIRES:

  1. KM 9.0+ (may work in KM 8.2+ in some cases)
  2. macOS 10.11.6 (El Capitan)+

TAGS: @FrontScreen @ScreenIndex @SubMacro

5 Likes