Following this idea here, I'm trying to find the fastest way to check for multiple occurrences of a word in the clipboard. In fact, you can reduce this task to finding a second occurrence of any word. This will already make a careful checking of the clipboard content (e..g. a translated sentence) necessary.
Clipboard contains one of these three example lines:
Macro gives either a warning when a word is found several times in (a sentence on) the clipboard or even displays a message/sticky note indicating the word in bold.
How about this approach?
- Save the clipboard content in oldClip.
- Determine the first word, via a regular expression looking for word boundaries or white spaces. (Or is there a concept of a word in Keyboard Maestro that I can use?) Assign the word to variable findWord
- Calculate the length of variable findWord as lengthWord.
- Replace all occurrences of findWord in the clipboard with nothing.
- Calculate the length of the clipboard: if the length of the clipboard is shorter than oldClip minus lengthWord, then several occurrences were found.
- Display a warning.
- Determine the second word and check for multiple occurrence.
I'm grateful for all suggestions!