Shorten URLs With A Quick Keyboard Shortcut In Windows

We recently showed you how to add URL shortening to Quicksilver, and now reader Kevin has made an AutoHotkey script so Windows users can enjoy quick, keyboard-based URL shortening.

Kevin was also nice enough to include some instructions for those that want to customise the script (which some may need to, depending on the speed of your internet or browser of choice). All you need to do to launch the script is hit Ctrl+Shift+B, and the current URL in Firefox will be shortened and copied to the clipboard. (Note, you can use another browser, but you'd need to modify his script.) You could change the shortcut if you want as well. The script is as follows:

; AutoHotkey Version: 1.x ; Language: English ; Platform: Win9x/NT ; Author: A.N.Other ; ;

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

waitTimeLoad = 700 ;; for slower internet connections, this number needs to be larger (in milliseconds) waitTimeKey = 200 ;; for slower computers, this number needs to be larger (in milliseconds)

^+b:: ;; delete this to make this script run once and stop (for keyboard launchers)

IfWinExist, ahk_class MozillaUIWindowClass ;; modify ahk_class for use with other browsers WinActivate

Send ^l Send ^c ;; put URL in clipboard

Send ^t Send Send ^v Send {Enter}

Sleep %waitTimeLoad% Send ^a

Sleep %waitTimeKey% send ^c

Sleep %waitTimeKey% ;; change this for your pc send ^w

msgbox %clipboard%`n`nShortened URL Copied to clipboard


Just throw it into your Startup folder or add it to your existing AHK startup script (You'll need AutoHotkey installed for this to work). Got any other tips for quick URL shortening? Share them in the comments! Thanks, Kevin!


    And for those of us that do not have AutoHotKey installed (for whatever reason) has a bookmarklet that you can bookmark at which presents a sidebar with interesting Facebook & Twitter stats.

    For those of us who use Chrome, has anyone got it working? I've tried changing the ahk_class to Chrome_WidgetWin_0, but it doesn't return a URL.

    As an alternative to the sleep command, you can use the statusbarwait command (I think it's that, not sure, don't have the program with me. Just search the help file.)

    @Ameoba, try that ^ and also try putting "sleep 10" between each of your "send" lines, just to give your computer time to process.

Join the discussion!

Trending Stories Right Now