Thursday, March 25, 2010

AutoHotKey – Easily Create An HTML Link

I’m huge fan of AutoHotKey which saves me a ton of time in not having to type repetitive keystrokes. Basically, it helps me be a better keyboard ninja.

Often for blog posts, I need to encapsulate a link with a HTML <a> anchor tag. So that http://Mehul.net becomes <a href=”http://Mehul.net” target=”blank”>http://Mehul.net</a>

So I’ve hacked up the following AutoHotKey script which allows you to highlight a link and press Control+Shift+L and it automagically converts into an HTML <a> anchor tag.

Copy this script into a autohotkey script. Load the script. Select an HTML link and press Control+Shift+L.


;-------------------------------------------------------------
; Create A Link -- Ctrl+Shift+L
;-------------------------------------------------------------

^+l::
{
Send, ^c
Sleep 50
var=% "<a href=""" . clipboard . """ target=""_blank"">" . clipboard . "</a>"
clipboard=% var
Send, ^v
Return
}

To learn more about AutoHotKey, check out these LifeHacker posts:

Turn Any Action into a Keyboard Shortcut

Hack Attack: Knock down repetitive email with AutoHotKey

No comments: