Open a website

with AutoHotkey

by Denis Lamarre
last updated May 30, 2014
difficulty.png Easy

by Denis Lamarre

Description

If you visit the same website often, and find yourself having to repeatedly open a web browser and search engine to find the website, then a keyboard shortcut to launch that website quickly would come in handy. This script allows you to do just that.

A quick way to access your most frequently visited websites means not having to keep those browser tabs open, and fewer open browser tabs means less demand on your computer’s memory.

Steps

1

stencil-v4-website.gifPrepare your overlay
Choose an unassigned key on the Enterpad where you will assign the website shortcut. Name it something appropriate, like the name of the website.

2

Code installation
Copy and paste the script below in the AutoHotkey script template file “Enterpad.ahk” at the location of the key you wish to assign. Replace the URL in the code (here, “www.google.com”) with that of your choice. (You can copy and paste the URL from the address bar at the top of your browser window.)

001:
run www.google.com
return

More Info

A URL ("Uniform Resource Locator") is the address for a given website, for example: www.google.com and www.yahoo.com.

Since URLs need to work across computing platforms, across the world, some special characters need to be encoded. For instance, a space is encoded as “%20” in a URL.

Due to these special characters, however, URLs occasionally present issues with AutoHotkey. If, for instance, a URL contains encoded characters, copying it as is in the script next to the Run command (as shown here) will not work in AutoHotkey:

run http://en.wikipedia.org/wiki/Overlay%20keyboard

Why? Because the percent sign is a special character that AutoHotkey uses to identify a variable. Therefore, in AutoHotkey you will need to add a backtick ( ` ) before any percent sign ( % ) in a URL. The script will become:

run http://en.wikipedia.org/wiki/Overlay`%20keyboard

As you may have guessed, the backtick ( ` ) is another special character used in AutoHotkey. In the event that a URL contains a backtick, you will need to add a backtick in front of it, too.

To make things easier, you may want to use the following script (and maybe save it as a key on your Enterpad) to automatically convert a URL that has been copied to your Windows clipboard. It will also insert the converted URL in your AHK script (wherever your cursor happens to be).

AhkFriendlyURL = %clipboard%
StringReplace AhkFriendlyURL, AhkFriendlyURL, ``, ````, All
StringReplace AhkFriendlyURL, AhkFriendlyURL, `%, ```%, All
SendInput {raw}%AhkFriendlyURL%
return

The first line of the script copies the clipboard content to a variable. So, the script won't modify the clipboard content. The use of {raw} in the fourth line is required to restore the AhkFriendlyURL variable without translating {Enter} as ENTER, ^c as Control-C, and so on.