revised AutoHotKey script

A couple of weeks back, I posted a semi-useful AutoHotKey script, just a little script to paste text from the clipboard, but stripped of formatting. Well, I did some searching, and of course, I’m not the only person to have come up with this basic script. This guy posted a similar script, a couple of years ago. The one thing I learned from his script, which I somehow didn’t think of myself, is that, rather than sending the clipboard contents using “SendInput”, it’s better to put the text back on the clipboard, then send ctrl-V. The reason this works better is that, in most applications, a paste is an atomic operation that’s easily undoable, whereas using SendInput appears to the application as though you just manually typed out the contents of the clipboard.
I also decided to disable the macro in Excel, since I have an existing macro in Excel that’s mapped to ctrl-shift-V, and I don’t want to override that. So, bottom line, the macro now looks like this:

#IfWinNotActive Microsoft Excel 
^+V::
myStr := clipboard
myStr := RegExReplace(myStr, "s+$","")
clipboard := %myStr%
Send ^V

Still nothing terribly amazing, but very useful, and something I was living without for longer that I should have.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.