How to have multiple triggers conditions?

Greetings!
New user here.
I am trying to trigger an apple script when two external volumes are mounted.
In the trigger section it says “trigger when ANY of the following:” occurs
What happens now is that the apple script triggers when either volume is mounted.
I need to trigger the apple script when ALL of the following:" occurs

I don’t see how to make this happen.
Is this possible? How can I achieve this?

DS

I got it to work.
In my case I wanted to trigger an apple script that synchronised two folders across two different external drives when they were both connected. The script will fail if both drives are not mounted.

Key for me to getting this to work was understanding that a trigger is an 'event' not an event 'condition'. A trigger is something that happens in a moment in time. IE When volume A is mounted something happens.

Wrongly, I started by triggering when either volume A or volume B is mounted and tried to find a way to get KM to recognise the 'condition' when both volumes are mounted as a 'trigger'. Needless to say when either event occurred the script got triggered and failed because both volumes were not mounted.

After much weeping, wailing and gnashing of teeth (combined with some reading!) I discovered that the macro is best triggered by mounting either volume but the action would would only take place if all conditions were met.

If there is a better way; please let me know!

DS

2 Likes

That is the correct way. As you discovered, triggers are always “any trigger will fire the macro”, there is no concept of “anding” because triggers happen on events which are always instantaneous.

You could not trigger on two different volumes being mounted because they would mount at different times (always slightly different times at the least).

The general solution is something like this: what you need is two macros, each with one volume trigger, and each with an If Then Else action and the Mounted Volume condition testing the other volume. If the other volume is mounted, then use the Execute a Macro action (https://wiki.keyboardmaestro.com/action/Execute_a_Macro) to execute a third macro that actually does the work.

Your simplified solution works fine as you have it.

Note that if you unmount one volume and then remount it, the macro would fire again - it would not require both volumes to be unmounted.

Thank you, I couldn't figure out how to group actions until I found your post!