Limit macros to just the "Save As" window?

Is it possible to have a shortcut (for example Ctrl+Alt+Cmd+B) trigger a macro (A) when the app is running, but when I have the Save As window open, the same shortcut triggers a different macro (B)?

It is working at the moment, but it's showing me the 2 options (A and B) when the app is running.

Screen Shot 2022-04-20 at 10.11.25 PM

I would like KM to completely ignore macro B when the app is running and ignore macro A when the Save As window is open.

Hope it makes sense...

Thanks! :slight_smile:

You'll have to test for something Keyboard Maestro can see like the [Save] button in the dialog.

KM cannot see the dialog window itself.

Given whether the button in question is or is not visible you can branch your macro appropriately.

2 Likes

Thanks for the tip. I guess that's a good thing to try. I will test it tomorrow, then!
I appreciate it! :slight_smile:

1 Like

@ccstone So I tried that and added an "if" action to see if there was a SAVE button, but the conflict window still shows, which is what I was trying to avoid. My goal was to have the same shortcut trigger 2 different macros, but if the save window is not present, it would completely ignore and wouldn't show the conflict window (and vice versa).
Do you have any other idea in mind?
Thanks!

One way you could achieve this it to have a third Macro that in effect just launches the other two Macros using an Execute Macro Action. This "calling" Macro would be the only one given the hot key.

In this "calling" Macro you put your If Then Action that checks if you are in a Save As Dialog and calls one of the two Macros.

It is probably neater to "call" them as Subroutines. In order to do that, you add a Subroutine Trigger to each of the two Macros and at the appropriate point in the calling Macro you use an Executive Subroutine Action. This new method (KM10) has several advantages over the old Execute Macro method (including, it is easier to see that the Macros are Subroutines and they can show you the Macros that call them).

https://wiki.keyboardmaestro.com:8443/Subroutines

And much simpler: If you don't want to end up with three Macros you could also consider putting all the Actions into one Macro and again using an If Then Action to decide what path to go down. As the two tasks in your example seem to be directly related I think this is what I would do. (And this is what @ccstone has already suggested in his post above.)

1 Like

And... yet another thought. Having the Conflict Palette pop up with something like this (two tasks that have the same hot key) can actually be a very good thing. Consider in three months time when you hit your hot key ⌃⌥⌘B and you have forgotten exactly what that does. You know that ⌃⌥⌘B has something to do with backing up and the Conflict Palette gives you a chance to decide which of your backup tasks you actually want before the Macros run. Completely automating the choice can actually be more annoying in the long run. The Conflict Palette is a simple way to manage easily remembered hot keys. In my case, when I hit ⌃⌥⌘B this pops up:

image

Thanks for the tips :slight_smile:

Yes, in general, the conflict window is useful. In this particular case, I wanted to have a shortcut that when the Save As window is open, it automatically makes a certain folder the destination of that Save As operation, so seeing the conflict would not be useful, especially if I'm including that macro in an automated macro (for example, something that runs at 5am).

So it's good that I'm learning new alternatives such as the ones you mentioned (Subroutines and all that... need to do that research).

I ended up setting Shift+Ctrl+B for all my backup tasks and then a different one for the Save As window so I can group my macros as much as possible.

Again, thank you so much for your input and tips :slight_smile:

1 Like

At the risk of recommending "something else" (mods, please delete if inappropriate!), Default Folder X does just this. It may do it a little too well for your needs, as (IIRC) it'll set the default for all the Open, Save, and Save As... dialogs for an application.

But you can also go to a default folder via hot-key/menu item from a non-defaulting dialog, so I'm thinking a KM macro that opens eg the "normal" Save As... then triggers the hot key might do the trick.

Check the manual to see if it might help, and what else it can do.

2 Likes

@Nige_S Thanks for the tip.
My reply wasn't probably clear enough, sorry.
What I mean is not that I want the Save As to open on a specific folder.
What I mean is that when I open that window and THEN I hit the shortcut that is the same as another macro (let's say shift+cmd+L is triggering 2 macros), then it would trigger a certain folder.

The issue here is not so much about the macro, because that's easy:
When the window is open I hit the shortcut
There's a keystroke for /
Then it types the path to the folder I want (let's say the Downloads folder)
And I'm good to go.

So far so good. The issue for me is that I would like KM to automatically know that Macro A is only for non-Save windows and Macro B is only for Save windows so if I'm using an app and I hit shift+cmd+L, it will not show the conflict window, because it knows that only Macro A is a working macro in that particular situation. If I'm in a Save window and I hit shift+cmd+L, then no conflict window either, because now it knows that in that particular situation, only Macro B is useful for that.

Does it make sense?

Pretty much like:
"If the Save window is closed, run Macro A. If Save window is opened, run Macro B".

The issue right now is that even if I use conditions such as "finding a button", KM first shows the conflict window, before it even goes to the macros themselves, so anything inside the macros is useless (I believe)

I think one of the options would be to create a master macro assigned to that shortcut shift+cmd+L and that macro would have a condition that if something that usually is present on the Save window is not present, it goes to Macro A, but if it sees that image or button that is typically on a Save window, it runs Macro B

Gotcha -- shame on me for answering a question you didn't ask!

Yep, seems like the solution is a branching macro, with or without subroutines, as suggested earlier. Although it would be nice if there was a "Suppress Conflict Palette" action -- I RTFMed, but couldn't see one.

1 Like

@ccstone Already answered this, and I suspect the reason a conflict palette was still appearing was that you still had the same shortcut assigned to the two submacros. Here is a simple calling macro example:

Screenshot

If you would like to be able to trigger the submacros directly, by all means give them unique triggers. If you always want to trigger them from the calling macro, they don't need triggers at all.

You don't need two separate macros for this. This should work:

Screenshot

If you did want all Save Dialogs to default to a certain folder as soon as they appear, you could do it like this:

Screenshot

1 Like

I ended up choosing different shortcuts for each, but if I need this kind of approach in the future and there's no way around it, I will definitely use the IF action and have a macro that branches :slight_smile:

1 Like