Front or Focused Window Title "is" vs Title "matches"?

Hey There,

I wonder what’s the difference:

Available when a focused window exists but title does not match

VS

Available when a focused title does not match

Also I wonder the difference between is VS matches

Thank you!

Regular expression match vs strict string equality ?

1 Like

Keep in mind that all actions have quick access to help via their gear or contextual menus.

Scope this out:

condition:Front Window [Keyboard Maestro Wiki]

Report back if you still have questions.

I carefully looked thru that webpage but still doesn’t understand

Such as the difference between is and match.

Difference between window title contain vs window exist title contain… what is exist and not exist…

The most practical use of the difference is if you want to match a few possible titles:

Match - would work with Apple|Orange|Pear to get a match if Apple or Orange or Pear is the title
Is - set to Apple would only work if the the Window title was exactly Apple

4 Likes

The first requires there to be a focused window -- "There is a focused window AND the focused window title does not match...".

The second doesn't care if there is a focused window or not -- "There is no focused window OR the focused window title does not match". So it will be available when no windows are open or all windows are minimised, as well as when the focused window's title doesn't match the regular expression.

Title is looks for a window whose title is exactly what you put in that actions field.

Match looks for a window whose title has what you put in the field, but whose title can contain other words as well. In other words, the title can be anything at all as long as it contains your “match”. It uses RegEx to do the matching. @Zabobon gave you an example of how that works, the vertical line | indicating that anything on either side of it is considered a valid match.

3 Likes

Nitpick -- that very much depends on the regex employed. For example, ^Untitled$ would make the Group available if the active window was titled "Untitled", but not if it was "Untitled 2".

True, but judging by the OPs initial question it sounds like they might not be familiar too familiar with RegEx so I didn’t want to complicate the issue by including anchors in my response. :sweat_smile:

Thanks, so match can do multiple keywords while is can be only one?

Is this the difference is?

I think contains also can do multiple words

It's not necessarily about "words" in either case.

  • Regular Expressions match flexible substring patterns which may or may not involve spaces.

  • Similarly, "puzzle" contains "zz".

There doesn't particularly need to be any space (or other boundary) between different words. A space is just another character in a pattern.


Another regular expression example:

The regular expression pattern ^p\w+e matches "puzzle", and it also matches "prime" and "puddle", and "pattern"

(anything that that has a 'p' at the start, and an 'e' later on, with one or more other lower-case alphabetic characters in between)


"contains" is less flexible – an exact substring is contained somewhere in the larger string.

No, "match" uses regular expressions while "contains" uses string matching.

@Zabobon's example is a regular expression -- "match either Apple or Orange or Pear" -- the hard-to-see | character between the words means "or". It would also match Snapple and Appear and Orange Squash... But regular expressions are very powerful and you can fine tune them to match only the pattern you want.

"is..." is an exact string match -- both things must be the same for it to be true, although it doesn't consider the case of characters. So Apple matches apple, but it doesn't match Snapple or apple pie.

"contains..." is one string contains the other -- again, case-insensitive. So Snapple contains Apple and apple pie also contains apple, but apoplexy doesn't contain apple -- all the letters are there, but not as an uninterrupted string.