Toggling Multiple Sized Windows

Hi everyone,

I'm wanting to toggle multiple macros with a single button on my Streamdeck. I'm learning Keyboard Maestro, but variables absolutely confuse me (I see a few posts on the subject, but they're not exactly what I'm hoping for).

Does anyone have suggestions on what actions to use and how to use them. This will really help me with my job if I can lockdown toggling the Macros.


What do you mean by "toggle"? Do you want to enable/disable multiple macros? Then perhaps put them all in a single group and enable/disable that with the Stream Deck button.

You may not even need to "toggle" them at all -- you can set your macros to only be enabled when certain apps are frontmost, for example.

If you mean something else, then tell us what you are trying to achieve -- "I've got a macro that loads a web page, another that launches Mail, and a third that logs me in to the work VPN. How do I fire off all three with a single SD button?". I find it easiest to do the things I'm asking about manually while writing each step into the forum post, then I don't miss anything important!

Hi Nige, thanks for responding!

I'm a film editor. I'm either in my editing software or on the Finder level throughout my day. When I open a "bin"(which is basically a folder) - the windows usually pop up somewhere I don't want them to.

This is how the windows look when you open a "bin":

I've created macros to put the bins where I want them. There's about 6 spots they need to be in depending on the task. I've started to program buttons on the stream deck for those positions - but I'm running out of space for other macros I need. The goal would be to have one button being able to toggle through the 6 positions until I'm happy w/ where it is.

Ah, you want to cycle through a bunch of preset window layouts, stopping at the one you're happy with.

I'll defer to the Stream Deck owners on the best way to do this, but I'm guessing you can do a "while button is pressed" or similar. In which case the quickest method would be to utilise the macros you've already written -- let's call them macro1, macro2, etc -- calling them from a "control" macro. The pseudocode for the "control" macro would be something like...

set a collection variable to "macro1","macro2","macro3"...
while SD button is down
    for each macroName in the collection
        run macro macroName
        pause 1 second
        if SD button is up
            exit macro
    end for each
end while

OK. I'm wrapping my head around the "code"/script. I've mostly run actions and never looked at the macro this way. I've been going through the MacSparky guide - but I don't think it really touches much on variables. Do you recommend somewhere I can study up?

Sorry, should have explained. Pseudocode like the above is more a "natural language description" of what you want to do that should (ha-ha-ha!) be easy to "translate" into your language of choice.

So I'm suggesting you set a variable to the names of the macros you've already written, 1 per line. Then, while the SD button is down, you run each macro in turn with a 1 second pause between them so you can choose to stop (by releasing the SD button) when you want.

I don't have a Stream Deck and I don't have your macro names, so I can't do much better! But perhaps a made up example will help...

Cycle Windows Example.kmmacros (4.5 KB)

Image of 'Controller' macro

There are 3 macros which simply put up a text window showing which they are. The meat is the "Controller" macro, which is triggered by F3 (change to suit) and for as long as F3 is held down will keep triggering each of the 3 macros in turn -- when you see a window you like, let go of F3 and it'll stop.

Biggest trick is that I don't think you can use a variable in an "Execute a Macro" action, so I've used an "Open URL" action instead. Hopefully one or more of the board's Gurus will jump in and tell me how to do it better!

The manual. It really is very good. Then look at macros here, try and figure them out, ask if you get stuck -- start with the above if you want. Then try and write macros to answer other peoples' questions -- when the problem isn't yours it's like starting with a fresh sheet of paper and you can get to try things you wouldn't normally consider.

Right, let's have a look at this. I think this is how I would do it. For the purpose of demonstration, I've chosen four arbitrary window positions.

Cycle Window Positions.kmmacros (47 KB)

Macro screenshot


If current FrontWindowFrame is equal to FrontWindowFrame of Position 1, 2, 3 or 4
Set window to Position 2, 3, 4 or 1 respectively

If current FrontWindowFrame is NOT equal to FrontWindowFrame of Position 1, 2, 3 or 4
Set window to Position 1

The result is that triggering this macro will cycle the window through the Positions. If it is currenly at one of your chosen Positions, it will continue the cycle in your chosen order. If not, it will start the cycle from Postion 1.

1 Like

Hi Nige,
That makes a lot of sense. I've been experimenting w/ "conditions" actions and I'm starting to get a feel for it. I'm going to take a look at your macro example now.

Thanks again!

Thanks so much for building that macro! I'm testing it now/mapped it to my Streamdeck. When I hit this macro button - the window goes to the top left position. However, that's the only position it'll move to. It's not cycling to the other window positions.

Hi Nige, I'm looking at at the variable "Local_theMacroNames". How do I add my existing macros?

Yes, this is because the values in the FrontWindowFrame conditions are currently set to work with my screen configuration, not yours.

Here's a new version of the macro which should be easier to set up:

Cycle Window Positions (Template).kmmacros (52 KB)

Macro screenshot

And here's a setup helper tool I've made for you:

Cycle Window Positions (Setup Tool).kmmacros (44 KB)

Macro screenshot

1: Click "Get" in the Window Position: Last → 1 action. Click and drag to draw a box where you'd like the window to be for Position 1.
2: Trigger the Setup Tool macro. It comes with the hotkey set as ⌃⌥⌘L.
3: Repeat as above for Window Position: 1 → 2, Window Position: 2 → 3 and Window Position: 3 → 4.
4: Click in the very first condition field and hit ⌘V to paste in the values from Window Position: 3 → 4, so that the cycle loops round from last to first.
5: Manually copy the four values from Window Position: Last → 1 to Window Position: X → 1.

NB: If you want more than 4 Positions, simply click the penultimate + button, as indicated, to add new ones.

Just change the text in that action to the names of your macros, one name per line.

Still no luck (although I'm learning a bunch). I just can't get the macro to run (I did enable it). Below are screenshots of my configuration. The Setup Tool is not doing anything. I didn't change anything in it.


Hmm. Not sure why that would be. Are the macros in a globally available group?


Turns out Keyboard Maestro was getting buggy and I had to simply close it and re-open. The window cycling is BEAUTIFUL.

Thanks to both of you for being exceptionally generous with your time! This was a great help.

1 Like

Glad to hear it!