If or else problem

Screenshot 2022-04-26 at 18.09.44

Hello,

So I'm trying to get keyboard maestro to recognise different words within the if or else function.

in the contain bar, I have, "Sound" and "Saturation".

I would like keyboard maestro to check if either of those two words are in the Safari URL.

I know I could just duplicate the If or Else and put each word in, but I plan on wanting to use more than just two words, I would like to have at least 10, it would just be easier if all the words were within the same If or Else.

Is this possible?

Thanks

Hi @keithrego21, try this:

matches: sound|saturation

2 Likes

Brilliant!!

I just tried it and it worked, I had to put the full URL in for it to work.

Thanks for the help!

1 Like

Excellent!

On the wiki Conditions page, here’s the pertinent information:

When talking about matches, note that “is” refers to equality, “contains” looks for a substring, “matches” uses regular_expression matching, and “conforms” refers to Universal Type Identifier matching (eg public.text).

It's quite possible that contains would have also worked in your case. Here's a simple macro that compares the two.


DOWNLOAD Macro File:
Conditions—contains vs matches.kmmacros (7.8 KB)
Note: This macro was uploaded in a DISABLED state. It must be ENABLED before it can be run. If it does not trigger, the macro group might also need to be ENABLED.

Macro-image

1 Like

Thanks for the detailed breakdown!

I have difficulty understanding most macros, so it will help me to read through it.

Do you have any recommendations on how I can improve my understanding of reading and creating macros?

@keithrego21, you are welcome. Glad to help.

It certainly depends on your learning style, but IMO here's a thread with some great recommendations:

Best Advice & Resources for Learning Keyboard Maestro Thoroughly - Questions & Suggestions - Keyboard Maestro Discourse

The MacSparky Field Guide is the most comprehensive training I've seen, but it is $50. Fortunately there's a good sample you can watch to determine if it's an appropriate investment for you.

I also suggest you experiment with simple macros that you already have or download here or elsewhere. One great feature of Keyboard Maestro is that it's easy to get context sensitive help from the Help menu accessible from every macro action.

2022-04-27 09.30.14

2 Likes

@_jims

Brilliant!!

Thanks for the suggestions.

The help menu is definitely something I will be using all the time.

Just wished I knew about this stuff sooner. as I've been stalling on trying to learn how keyboard maestro works

anyway.

Thanks mate, Much appreciated

2 Likes