Don’t get a new keyboard, just use AutoHotkey!

Posted: January 27, 2011 by jellymann in computers, fixes, hotkeys, keyboard, windows

My Escape key stopped working today. After freaking out for a few minutes about where I’m going to get the money to buy a new keyboard, I made a quick AHK script that remaps the Caps Lock key to Escape. Then I realised that I would probably tap it by accident doing some irreversible damage while typing, so I thought I’d remap Scroll Lock to Escape (Who uses scroll lock, anyway?):

ScrollLock::
{
Send {Esc}
return
}

On the topic of Caps Lock, everyone know how annoying it is when you accidentally press it and your wall post's mood changes significantly. SERIOUSLY ANNOYING. So here is how to remap the Caps Lock key to something else. In this case, it acts as a third Control key:

CapsLock::Ctrl

If you sometimes do need to use the Caps Lock, like when you're flaming a forum, or coding a serious error message, you can map Shift+Caps Lock to toggle Caps Lock. I tried doing it like this, which is the way most people did it in the foums:

+CapsLock::CapsLock

But unfortunately that only turned Caps Lock on and not off. And since my Caps Lock key is remapped to Control, I couldn't turn it off without killing the AHK script.

The following script does work, as it checks the state of Caps Lock and then acts accordingly:

+CapsLock::
{
if GetKeyState("Capslock", "T")
SetCapsLockState, Off
else
SetCapsLockState, On
return
}

I've always wanted my scroll wheel to be an easy volume-control, as my keyboard does not have media keys. I Googled and went through forum after forum to find out what AHK commands control volume, but none of them worked right. Then today I stumbled across something. The media keys are keyboard keys after all, and can be mapped and remapped in AHK just like any other, even if your keyboard doesn't have them. Here is a simple script that uses the scroll wheel and middle mouse button to change and mute the volume:

#MButton::Volume_Mute
#WheelDown::Volume_Down
#WheelUp::Volume_Up

When in doubt, consult the AutoHotkey Key List.
I also recommend you also take a look at my other post on AutoHotkey.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s