The digital pen on the Surface Pro 4 and Surface Book is an indispensable tool for serious note-takers and artists alike.
Out of the box, the Surface Pen is pre-programmed to do some pretty wonderful things. For example, the eraser can be single-clicked to open Microsoft's OneNote, double-clicked for a screenshot, and you can press-and-hold to open up a Cortana search. Oh, and the eraser erases, too!
But what if you wanted the eraser to do something else? If you install the Surface app on your device, you can disable the default actions, or replace the gestures to launch any store or desktop app instead. However, that's as good as it gets with Microsoft's built-in options.
If you want to go beyond the basic customizations, you'll need a free program called AutoHotkey, which lets you reprogram the eraser to do pretty much anything. Time to start scripting!
- Don't Miss: Top 7 Surface Book Hacks for Artists
First things first, you're going to need to download and install AutoHotkey.
Once AutoHotkey is installed on your Surface, you're going to need to create a new script file. To do this, right-click on your desktop, go to New, click AutoHotkey Script, and then name your new script file. Make sure the name of your script ends with the extension ".ahk" for the script to execute.
This will create a new script for you to edit and place on your desktop. To edit your new script, you will need to right-click on the script you just made and then click Edit Script. The script will then open in Notepad.
Scripting may be scary to some of you, but AutoHotkey isn't really all that bad, and we're going to show you how to write some basic scripts. Here are the identifiers for our three functions:
- Single-click is #F20
- Double-click is #F19
- Click and hold is #F18
Warning: There is also a side button on the new Surface Pen, which, by default is set to right-click. The identifier for right-click is rbutton. This is a tricky function to reprogram as once you've changed right-click using a script, it affects right-click functionality across the entire system. Best to steer clear.
Before we do anything, we will need to decide which function we wish to modify. So, for example, let's start with our single-click eraser function. For single-click, we start like this:
Everything to the left of the "::" defines the function we are using, so, in this case, a single-click of the eraser. We then start a command string. As an example, let's look how we would script an undo (Ctrl + Z) function.
- #F20 :: ^z
So, in this example, control is represented by the symbol "^", and, in conjunction with "z", it gives us the undo command. Return ends the command string. Pretty neat right?
Let's look at another example, where we'll script single-click to copy and double-click to paste.
- #F20 :: ^c
- sleep 300
- #F19 :: ^v
Following the same basic format, we first define our single-click as Control + C. Sleep is a command to add time (in milliseconds) before the next function can operate. We use 300 ms to give the system ample time to copy the selection to the system's clipboard.
You can also program the eraser to launch applications as long as you know the name of the executable. However, this is already a feature that Microsoft gives in their Surface app, so you could easily use that as well. Just for learning purposes, let's see how it works in AutoHotkey.
- #F20 :: Run photoshop
This simple command line will allow Adobe Photoshop to open with a single click from your Surface Pen's eraser. Being able to launch a program in this fashion only works with certain applications. This means that with most applications you will need to run the entire path (e.g. Run, %A_ProgramFiles%\Some_Program\Program.exe).
To open a website, the script would look like this:
- #F20 :: Run, https://www.wonderhowto.com/
This will program a single-click from your Surface Pen eraser to open the specific link in your default browser. Needless to say, these examples are rudimentary, and, really, the possibilities of how you can program your Surface Pen's eraser are endless; these examples are just to get you going. For more elaborate scripting, visit the AutoHotkey forums.
To run your new script, make sure you first save your script with the .ahk extension, then, right-click your script file and click Run Script. You can also compile the script to make a .exe if you wish.
An AutoHotkey icon will appear down below on your Windows taskbar letting you know the script is running successfully, and, to stop the script, simply right-click the AutoHotkey icon down in the taskbar and click Disable.
We hoped you enjoyed customizing your new Surface Pen's eraser and we encourage you to experiment with your own scripts. Let us know what you think or perhaps share a script idea of your own down below in the comments or on Facebook, Google+, or Twitter.
Keep Your Connection Secure Without a Monthly Bill. Get a lifetime subscription to VPN Unlimited for all your devices with a one-time purchase from the new Gadget Hacks Shop, and watch Hulu or Netflix without regional restrictions, increase security when browsing on public networks, and more.
Other worthwhile deals to check out: