How to Compare the Clipboard Contents With a Blacklist?

Thank you, Chris. This is very useful. New puzzle will be how to build this into my original macro.

This seems to be exactly what I'm looking for, but I'm doing something wrong.

I have a macro that I don't want to be triggered when certain windows are in focus. I've set the names of each blacklisted window, one per line, to a variable. I'm then trying to see if the WindowName contains any of these lines, but it isn't working. Any ideas?

In the If action, try "matches" rather than "contains". You want the (?i) prefix evaluated as part of a regex ("matches"). Your version instead is looking for the literal string "(?i)" ("contains").

Hey Neil,

If you want to use “contains” then remove the “(?i)” prefix to the variable, otherwise Steve's suggestion should work.

-Chris

Thank you both.

Unfortunately it's still not working for me.

I'm easily confused by KM, but I'm wondering if it has anything to do with FrontWindowName showing as blank in preferences?

I tried another one from scratch to see if I made a mistake along the way. This time I tried a whitelist, and it shows as "currently true", even when the variable doesn't match any lines.

First, regarding FrontWindowName: You want to use the FrontWindowName token, as opposed to a variable. If your list of KM variables has an entry with that name, that means you've created a variable with the same name as the token. The value of the variable is whatever you set it to be (apparently not currently set), but it's unrelated to the value of the token. Whether a KM action refers to the variable or the token would depend on context.

With respect to your specific screen-shot above, because Local variables only exist during execution of a macro, the editor generally doesn't have access to those values, and so any "currently true/false" report based on a Local variable is not what it seems.

1 Like

Somehow I missed your reply. Removing Local fixed it. Thankyou very very much!

This was working perfectly yesterday. Started my mac today and... Can you spot my mistake?

:pray:t3: