Window management on multiple displays

Hi there,

I paid for Moom but stopped using it for simplicity. My KM macros do all I need except for one thing: still can't get multi-display right, unfortunately.

Main issues:

  • Can't for the life of me make a window occupy 100% of the screen on the current display where it seats

  • Can't find a flexible "Move to Next Display" solution. Mine works fine with 2 displays but when I connect a 3rd one to my mac it will still only cycle between the first two : /

Does anybody please have some light?

Thanks a ton!

Bruno

1 Like

You used:
image

To use the screen where the window is frontmost, use:
SCREENVISIBLE(Front,Left)

For details, see SCREEN function.

You will probably need a Repeat action to go through all screens to find which screen you are on, and which is the next screen. There is no next screen function.

Here is an example macro that will determine the Current and Next Screen Numbers. You can use those numbers to manipulate the FrontMost window as desired.

Questions?


Example Output

image


MACRO:   Get Next Screen [Example]


#### DOWNLOAD:
<a class="attachment" href="/uploads/default/original/3X/5/8/587d2df567ae126e9ab6f99388d785ae89a85443.kmmacros">Get Next Screen [Example].kmmacros</a> (10.0 KB)
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**

---

### ReleaseNotes

Author.@JMichaelTX

**PURPOSE:**

* **Get Next Screen Number**

**HOW TO USE**

1. Select the Window that you want to manipulate
2. Trigger this macro
3. This macro will provide the Current and Next Screen Numbers
4. You can use it in your own macro to manipulate the FrontMost Window as you like.

**NOTICE: This macro/script is just an _Example_**

* It is provided only for _educational purposes_, and may not be suitable for any specific purpose.
* It has had very limited testing.
* You need to test further before using in a production environment.
* It does not have extensive error checking/handling.
* It may not be complete.  It is provided as an example to show you one approach to solving a problem.

**REQUIRES:**

1. **KM 8.0.2+**
  * But it can be written in KM 7.3.1+
  * It is KM8 specific just because some of the Actions have changed to make things simpler, but equivalent Actions are available in KM 7.3.1.
.
2. **macOS 10.11.6 (El Capitan)**
  * KM 8 Requires Yosemite or later, so this macro will probably run on Yosemite, but I make no guarantees.  :wink: 


**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.  😉
.
* Assign a Trigger to this maro.
* Move this macro to a Macro Group that is only Active when you need this Macro.
* ENABLE this Macro.

**USE AT YOUR OWN RISK**

* While I have given this limited testing, and to the best of my knowledge it will do no harm, I cannot guarantee it.
* If you have any doubts or questions:
  * **Ask first**
  * Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.

---

![image|574x1713](upload://b8w6eyQ7wBEerIeoEkBYRCKk5tx.jpg)
2 Likes

Wow, thanks a ton!!

1st issue is totally solved.

The 2nd one (the one you made the macro for) didn't, unfortunately. I don't get the prompt window showing the number of screens — which would be the expected output, right? I am currently working with just my laptop's screen, zero external displays. Could this be the cause, perhaps?

Thanks again,
Bruno

Did you get any type of notification that the macro failed?
I'm not sure what you mean by "prompt window". There is NO prompt window, only a Display Window, which should show even with just one screen:

image

Had something set up incorrectly, things are working as expected now (I do get the pop up with the data).

This is what I'm currently using to send the frontmost window to other displays. Do I need to pipe the output of the previous command into this? Don't know how to do that as I haven't used variables in KM yet, can you pls outline the basic syntax?

I haven't really read the docs for how the window manipulation stuff works, do you pls know of a quick way to just "always send foremost window to the next display"? Better yet if it can go to the same or similar position as it was before but that's not a requirement.

This is really all I need to not need Moom or any other window manager outside of Keyboard Maestro.

Thanks again for the help!

Hi @JMichaelTX,

Finally had time to read through the documentation. Quite clear and useful!

What I can't do, unfortunately, is use the "Local__NextScreen" variable on your script on my "Move Front Window to Position" action. It's a Calculation (C) field and unfortunately is not reading from the variable.

image

Works just fine. But any way I try to use the variable fails, unfortunately:

image

Any idea on how I could fix this, pls?

Thanks a bunch!

Hi @orsini,

The answer, fortunately, is quite easy once you know that calculation fields don't require the %Variable%[VARIABLE]% syntax to reference variables. Just use the variable name as-is and it should work (as you've already done in the first field of the action):

image

Oh, I assumed the red parameters meant bad syntax! Why are they red?

Things weren't working because for some reason part of the macro doesn't work on the KM window itself... But it is working like a charm on all others now.

Thanks a ton for the help!

No problem! I'm afraid I can't explain why the parameters are red here, but as for the macro working on the KM window itself, I can point you to this recent thread, which shows how to manipulate KM windows by adding the Keyboard Maestro Engine to the list of applications KM can see.

The parameters are red because currently (always in fact except when the macro is actually running), the Local__NextScreen variable does not have a valid number and so the expression is invalid. The highlighting is incorrect, it should show the Local__NextScreen variable in orange since it is the problem. And even that should not happen since it is a Local variable it can never have the correct value outside of the macro execution.

All of these are on the todo list to look at resolving.

1 Like

Great. Thanks for the update Peter (and thanks again Gabe and JMichaelTX). Things are working great for me now and KBM is now my only window manager, really great stuff.

1 Like

I came up with a slightly different solution. I have three screens, but of course you can add as many as you need. If there's any benefit to doing it this way, it's that you can specify the cycle order.

image

1 Like