Trying to toggle two app screens side by side

I'm trying to toggle the display of two app screens side by side. I have the toggle part done by using the "If/Then" action, however I cannot get the screens back to their full size. I don't want to have the apps maximised just back to full size.

I then used the Move & Resize action thinking they would affect the position and size of the windows, but after the windows goto 50%, I can’t get them back to full size.

Could someone point me in the right direction on this, thanks.
Setup Prompter.kmmacros (10 KB)

I might not fully understand your question but it sounds like you want the apps to go back to fullscreen and not simply maximized? I ask because sometimes there's confusion between those two terms...

Either way, a good place to start would be specifying the application in your move and resize window actions. Otherwise they might be repositioning the front window in whatever app was at front before the app in question was activated in the event it doesn’t activate faster than KM runs the next action.

If your question is how to make an app go fullscreen (which typically hides menu and task bars), then your move and resize actions are not going to do that. You likely need to use a select menu item action pointed to the app's menu option to enter fullscreen. Unfortunately I don't have either one of those apps to show you but here's an example using Keyboard Maestro's menu item:

Here are screenshots of what I'm trying to achieve. I'd like to be able to just toggle between the two offerings. One is side by side so I can read the script while recording and then go back to a maximised application screen.


Ah ok, that is referred to maximizing the app (not fullscreen). In that case you have a couple of options in the "otherwise" portion of your macro:

  1. Insert a pause until app is at front after your activate actions, that way the next action adjusts the correct window (since it's looking at the front application)
  2. or better still, specify the application you want to adjust the window in the move and resize window actions. Because right now, if those actions are triggered too fast, and the app you just activated is not at the front, then they will not reposition the correct window. So specify the apps via the very bottom portion of those actions.

I adjusted the script as per your suggestion with no affect to the operation of the macro.

If I set the application windows to 50% and I trigger the action, the apps expand to fullsize as expected, but they won't go back to 50% on subsequent keypresses.

Oh ok I see now. I thought your issue was maximizing them, but it’s actually splitting them. The reason that isn’t working is because none of those apps are full screen which is what the If condition is set to.

I’ll take a closer look at it after dinner.

EDIT: Hey @Potts_Jeff take a look at this macro I built sometime back. It determines if the front window is maximized or not. It displays that in a notification, as well as highlights the visible screen area and front window area.

You can use the logic behind it to get your macro working properly. If you need help implementing it just let me know and I'll be glad to help further.

Determine if front window is maximized.kmmacros (6.5 KB)

Macro screenshot (click to expand/collapse)

So I took your script and I bludgeoned it a little and although not an elegant solution, it does work. What am I missing to make this more solid or more refined?

Keyboard Maestro Actions.kmactions (6.9 KB)

I'm glad you got it working. What about it is not elegant, and what do you mean by "solid" and "refined"? just curious since it's a fairly simple macro (though not one I personally use) and I'm wondering what you had in mind.

I was just woinderring if there was a programmatically more sound or efficient way of obtaining the same result. I think of it as more of a learning exercise since I'm in no way a very technically savvy or proficient user KM.

Thanks again though for your direction.

Gotcha! There might be, I'm just not sure of other ways of doing it to be honest.

Follow on question,I'm getting unpredicatable behaviour when using an external second display. What actions should I be looking at to make my macro bulletproof in either situation?

Define "unpredictable behavior" please. :wink:

When the menubar is on the external monitor, I assumed that using "Main" in screen calculations wold refer to the screen containg the menubar. However, one application properly resizes to the external monitor when it is fullsized or when it is resized.

The second application jumps from the external monitor to the laptop screen when it is being resized.

I find it unpredictable since I use the SCREENVISIBLE(Main,X) for positioning.