I was catching up on Penny Arcade today, and Gabe was talking about his Microsoft Surface Pro. I like reading these, because only people who have one truly know what the device is like. I love mine, and it seems everyone who has one loves it.
Right at the end, he mentioned how he wished he could map some functions to the volume keys when drawing. This made me giddy, because I could help! I’ve spent full days programming AutoHotKey for use on my Surface Pro in various circumstances, so I could talk at length about the subject.
The regular stuff is easy, so I won’t spend much time talking about that. The hard stuff is platform-specific quirks, and how buttons on specific devices work. So here’s a list of things to keep in mind when programming AutoHotKey on Surface Pro.
Surface Pro has a one-piece volume rocker flimsy enough that you can press both buttons at once, a power button, a capacitive Start button, and a capacitive touch-screen. Microsoft got around some limitations by including their own hotkeys and implementing some good touch events.
Here are the keys and the associated scan codes in AutoHotKey:
Volume Up: SC130
Volume Down: SC12E
Start Button: LWin
Tap the screen: LButton
Tap and hold: RButton
Pinch: Ctrl + WheelDown
Spread: Ctrl + WheelUp
Start + Volume Up: LControl + LWin + F14 (Assistive Tech)
Start + Volume Down: LWin + F15 (Save screenshot)
Start + Power Button: LAlt + LControl + Delete
You can capture any one key plus modifiers (Ctrl, Alt, Shift, Win) in AutoHotKey, and then send some other events when those buttons are pressed. You can also specify one button and another button, which turns the first one into a modifier. After that, holding the first button down won’t do anything until you press another key or release the first one.
So if you did something like this:
SC12E:: SendEvent ^{z}
An ‘undo’ command would be sent again and again while you held volume-down, as if you were holding Ctrl and Z on your keyboard.
But if you then did this:
SC12E & SC130:: SendEvent ^{l}
The volume-down button would only work when you released it, so you’d have to click-click-click-click-click to undo several steps.
There are workarounds, but keep that in mind.
Seeing as you can’t do anything complex like Volume Down + Ctrl + Volume Up, we’re a bit limited with what we can capture. Here’s a list of all the current possibilities using only the tablet buttons:
SC130 (Volume Up)
SC12E (Volume Down)
SC130 & SC12E (Volume Up and down)
SC12E & SC130 (Volume Down and up)
LWin (Start button)
SC130 & LWin (Volume Up and Start)
SC12E & LWin (Volume Down and Start)
*F14 (Start and Volume Up)
LWin & F15 (Start and Volume Down)
LButton (Tap)
RButton (Tap and hold)
LButton & LWin (Tap and Start)
RButton & LWin (Tap-and-hold and Start)
SC130 & LButton
SC130 & RButton
SC12E & LButton
SC12E & RButton
LButton & SC130
RButton & SC130
LButton & SC12E
RButton & SC12E
^WheelDown (Pinch together)
^WheelUp (Pinch apart)
!^Delete (Start and Power)
24 possibilities. 15 Good ones.
(You don’t want to put LButton or RButton first, or your taps won’t do anything. Also, the Ctrl+Alt+Del combo sends that even when you change it, so you’ll always be confronted with the annoying option screen.)
Note that the Start button cannot be held down. It only activates when you release it, ignores touches it thinks you made by mistake, and only activates once every half-second with repeated taps.
Obviously, using LButton & Something else means your clicks are going to be intercepted and you won’t be able to click on anything. Likewise with RButton, but in something like Chrome that’s already disabled.
Even if you keep things simple, you can get several handy shortcuts by using AutoHotKey. It’s pretty nice! If you’re struggling to remember all those volume combos, I think of Volume Down + Volume Up as an uppercut, and Volume Up + Volume Down as a drop-kick. You start in one direction, but end up in the other.
Here are a couple lines of code for things I did to fix a couple things I changed:
; ‘IfWinActive’ matches based on keywords anywhere in title
SetTitleMatchMode 2
; By pressing Alt and the volume key, it acts normally (note you need the ‘virtual key’ code as well as the scan codes)
!SC12E:: SendEvent {VKAESC12E}
!SC130:: SendEvent {VKAFSC130}
; Just making sure that I can swipe open the charm bar anytime I want to change the volume.
#IfWinActive Charm Bar
SC12E::SendEvent {VKAESC12E}
SC130::SendEvent {VKAFSC130}