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.
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:
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: