Hi, I'm trying to make a macro that adds a markdown checkbox to the current line. I got something that works, but it’s pretty slow - about a second. I tried both shell script and AppleScript, but they’re about the same. I’m wondering if any of the actions I'm using are particularly slow and could be replaced.
Shell scripts have some overhead, and AppleScripts/JavaScripts have a fair amount of overhead, so unless they are doing fairly complex things, they are likely to be slower than direct actions.
I used the named clipboard to not overwrite the main clipboard. I can’t type out the characters here because it’s being converted to a checkbox , but it’s inserting a checkbox markdown at the beginning of the line. It’s stripping out the leading dash if present so I can convert a regular bullet to a checkbox.
Thanks for the suggestions! This is what I ended up with. I think now the initial keystroke to highlight the line is the slowest part, but it’s definitely better now
That will not work - there is only one way to copy or paste things on the Mac and that is via the system clipboard.
You can, but it is generally not recommended (at least by me) for the reasons described here (essentially because the system clipboard is synchronously changed, but the paste is done via a keyboard event that is queued, and thus deleting the clipboard you wish to paste can result in the previous clipboard being pasted).
I should have been clearer, because that's an obvious concern: I delete the entry I added long after the paste event. I realize the clipboard could have been changed by myself or some other app in the interim, but that's not generally a concern with my macros, because when they're running, they're running and have full control of my Mac—so the only way the clipboard changes is if they change it.
I do have a small number of periodic and/or background macros, but none of them work with the clipboard.