Is a Number within a Specific Phrase in the Clipboard is in a Range

Suppose I had a constantly changing clipboard with several numbers in it. However, the only number I am interested in is the number that comes after the word Chapter (e.g., Chapter 49). How can I create a macro that will determine if the number after Chapter (while ignoring all other numbers in the clipboard) is between 1 and 100? Thank you in advance!!

Something like this?

Chapter Number v1.00.kmmacros (6.7 KB)

Macro Image

Keyboard Maestro Export

1 Like

Wait... What?!

1 <= local_ChapterNumber AND local_ChapterNumber <= 100

I mean, it's obvious when you see it. But there's no mention of AND (or OR) on the Calculations page and it isn't listed in the Operators table, a search of the Wiki for "boolean" throws up nothing relevant, and I even lamented not being able to use such logic directly a few months ago (and I'm sure I tried AND as well as the bitwise & and the post's desperation &&).

I am going to be so annoyed with myself if I've missed something obvious!

1 Like

I've posted AND/OR solutions on the forum at least a couple of times now, and I believe I discovered the feature simply by trying it out while attempting to solve someone's problem.

@peternlewis – this doesn't seem to be documented on the Wiki...


AND, OR, and XOR are documented in the operators listing.

Bitwise OR (|), Bitwise AND (&) and Bitwise XOR

Keyboard Maestro defines false as 0 and true (as far as comparison operations go) as 1.

So AND and OR and XOR as bitwise operations are synonymous with logical operations, unless you start expecting 2 to be “true”.

1 < 2 AND 3 < 4

evaluates as:

  • 1 < 21
  • 3 < 41
  • 1 AND 1 ➤ 1

If you tried to do something like 2 AND 6, that will give you 4.

Keyboard Maestro has no specific logical and, it simply uses the bitwise AND.


Yes! Thank you so much!!

Then I think I misunderstood because the operators we can use in KM are code-marked while the "AND" etc synonyms are in plain text -- I read it as "The Bitwise OR, for which you use the pipe character...".

I should have realised my mistake on seeing that XOR has no character listed.

Thanks as always, @peternlewis, for the helpful explanation.


Hey Peter,

It seems to me this deserves a short explanation in the Wiki, because 98% of people will have no idea of what bitwise operations are even if they research it online.

More people will use the feature if they understand what it can do for them.