Clipboard conditions "has text" and "does not have text" not working

In a text editor, I make sure that nothing is selected. I then run a Keyboard Maestro macro that does the following:

  • Sets the system clipboard to an empty string (i.e., clears the clipboard)
  • Types ⌘C (i.e., copies the selected text to the clipboard)
  • Tests if the clipboard “has text”.

The condition always tests true.

If, on the other hand, I run a macros that does the following:

  • Sets the system clipboard to an empty string (i.e., clears the clipboard)
  • Types ⌘C (i.e., copies the selected text to the clipboard)
  • Tests if the clipboard is an empty string.

Then the test runs properly.

What am I doing wrong with the first macro? It seems like the “has text” and “does not have text” conditions are not working.

“has text” is talking about the type of data on the clipboard.

So if you set the clipboard to an empty string, the “has text” will be true - there is some text on the clipboard, which happens to be the empty string.

If you set the clipboard to an image, then “has text” will be false.

Command-C with nothing selected will not change the clipboard, but I presume you know that, you’re trying to detect it.

Personally, I would do something like this:

Set Clipboard to "KMEMPTY"
Command-C
If Clipboard is not “KMEMPTY”

Awesome. Thanks.

If you are trying to determine whether or not the user has made a selection, and whether or not the clipboard has changed, you might consider this approach:

1 Like

Thanks J for posting this.
It helped me when I was looking for some answers!
Happy Holidays season!

1 Like