devxlogo

Use AutoHotKey to Write a JavaScript Bookmarklet to the Browser Window

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 del.icio.us. You’d do something like this:

^d:: Send !d Send javascript:location.href='http://del.icio.us/post?v=4;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 del.icio.us (this assumes, of course, that you’ve got a del.icio.us 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 Del.icio.us 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='http://del.icio.us/post?v=4;url='{+}encodeURIComponent('http://'{+}location.hostname);{Enter}return

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

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist