How to check if nothing was copied (make a markdown bolding macro)

I have this macro:
g: markdown bold quote.kmmacros (25.3 KB)

I want to make a macro that will make the text bold if I select some text. If nothing is selected however, I want it to add the stars as if I want to make the bolded text.

The above macro fails for me, because the clipboard changes sometimes even when my cursor stands still. Not sure how I can get around that.

Thank you for any help.

You might like to have a look at this macro and the ideas that developed from it in the discussion below.

Essentially it allows you to paste from the clipboard by using the key sequence vvX

X is a variable or ‘switch’ which governs what will be pasted. So for example, the sequence vvp pastes the clipboard in uppercase, while vvl will paste in lowercase. You will see that subsequent adaptations allowed for vv*, which could work for you?

Checking to see if the clipboard changed is exactly what the CLIPBOARDSEED() function is for. I even have a set of actions stored in my KMFAM to make it easier to write macros that take advantage of it:

Check That Clipboard Has Changed.kmactions (1.5 KB)
26 AM

What may not be obvious about these is that the "Copy" action is modified to timeout after a few tenths of a second without notification or aborting the macro.

Here's how these actions would work with your use case:

g: markdown bold quote.kmmacros (3.3 KB)
24 AM

Maybe try this and see if it works any more reliably?

1 Like

this is EXACTLY what I was looking for. Thank you, sir!

1 Like