Use AutoHotKey to Write a JavaScript Bookmarklet to the Browser Window

To make a hotkey that does something complicated in the browser you will probably need to send a JavaScript bookmarklet to the browser address bar. For example, suppose you wanted a hotkey that sent the current page as a bookmark to You’d do something like this:

^d:: Send !d Send javascript:location.href=';url='{+}encodeURIComponent(location.href);{Enter}return

The above code re-maps the combination of the control key (^) and the d to send alt-d (the ! in AutoHotKey is a shortcut for alt) followed by a JavaScript URL which sends the current location.href to (this assumes, of course, that you’ve got a account and are logged in).

The {t} and the {Enter} will send the + key and the Enter key respectively, the curly brackets are used as escapes in AutoHotKey, and the + sign is generally used as a shortcut for the shift key.

Obviously, you could make variations in the hotkeys by mapping a key combination to send a JavaScript passing the address of the current page and mapping another key combination to pass the domain of the current page. For example:

^q: Send !d Send javascript:location.href=';url='{+}encodeURIComponent('http://'{+}location.hostname);{Enter}return

Click here for a more in-depth discussion of hotkeys that send JavaScript.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: