It’s no secret that we’re huge fans of using the AutoHotkey scripting language, and we use it religiously to automate Windows tasks and save time. Here’s a handful of useful scripts and tricks to help you become an AutoHotkey expert.
Today’s lesson assumes that you’re already somewhat familiar with AutoHotkey scripting and automation. If you’re new to the world of AutoHotkey, be sure to check out our beginner’s guide to turning any action into a keyboard shortcut using AHK.
Note: If you’re trying to use an AutoHotkey script that requires Administrator access, you’ll probably want to use this registry hack to add Run as Administrator to AutoHotkey scripts.
Make Windows Explorer Easier to Use
Show/Hide Hidden Files and Extensions: If you regularly need to access hidden files, it’s a pain to have to dive all the way into the settings dialog to enable them, deal with the file and then go back and set it to hidden again. Instead, try a simple AutoHotkey script to toggle hidden files with a shortcut key — and as a bonus, you can also toggle file extensions with a shortcut key.
Restore the Backspace Key to XP-Style Navigation: Windows XP used to let you go up in the folder structure when you used the backspace key, but since Vista the backspace key has been changed to go back in the history instead — sure, you can use the alternative Alt+Up hotkey, but if you just can’t get used to it, you can use an AutoHotkey script to restore the backspace key to its original purpose.
Quickly Access the Command Prompt: If you’re a command-line junkie, you’re probably already aware of how easily you can access the command prompt from the context menu, but if you want something even easier, you can use AutoHotkey to create a shortcut key that launches a command prompt already started in the same folder that you’re currently browsing in Windows Explorer.
Insert Special Characters with a Keystroke
That’s all fine and good for special characters you don’t really use that often, but if you find yourself using the same special characters on a regular basis, you can use AutoHotkey to insert any special character with a single keystroke and save yourself loads of time in the process.
The general idea is that you’ll use the SendInput function in a hotkey script and paste in the special character that you’re trying to use between the brackets — for instance, if you wanted to assign Alt+O to send the registered trademark symbol, you’d use a script like this:
You can modify the hotkey line to send any symbol that you’d like, and simply include multiple lines if there’s more than one symbol you’d like to assign to a hotkey.
Manipulate Open Windows with the Keyboard
Activate Favourite Applications with a Keystroke: If you regularly have loads of open applications on your screen, switching between them with Alt+Tab can be a royal pain. The much easier solution is to assign a shortcut key to a particular window so you can instantly restore a specific, commonly used application with a single keystroke. You’ll need to customise the script for your environment and then learn the shortcut keys, but once you do, you will never want to go back to using Alt+Tab again.
Alt+Drag to Move Any Windows, from Anywhere: Long-time Linux users have always had a great feature that lets you hold down the Alt key and then left-click dragging the window anywhere on the screen that you want — instead of trying to grab the title bar every time you want to move it. Since this functionality doesn’t exist in Windows anywhere, you can use an AutoHotkey script to get the Alt+Window drag functionality in Windows.
Turn Off the Monitor and Lock the PC in One Keystroke
If you’re using a desktop PC, you could always just hit the power off button on the monitor, but then you’d have to power it back on again every time you sit down — this method uses Windows power management to shut down the monitor, and then you just need to move your mouse or hit the keyboard to force it to come back.
Create a Customised Boss Key to Keep You Out of Trouble
If you’re still stuck in the daily grind, you’ve no doubt been in the situation where you’re trying to do something else while you’re supposed to be working for the man — and you don’t want to get caught while doing it. We aren’t actually advocating that you slack off at work or violate your employer’s policies, but if you are already slacking off, you can create your own customised boss key to keep you out of trouble.
The general idea is that you probably already know the applications that you aren’t supposed to be using, so you can create a shortcut key that hides or kills the windows that you shouldn’t be using, and then create another shortcut key that restores them again.
For instance, if you wanted to hide VLC media player when you hit the F6 key, and then show it again when you press the F7 key, you’d use a script similar to this one:
WinHide, VLC media player
WinShow, VLC media player
You could make a more complicated script that detects the presence of the window and toggles with a single shortcut key, but the problem is that if you accidentally hit the key twice, that application is going to hide and come right back — not what you’re trying to accomplish. For more tips and techniques, be sure to read through our guide to creating the perfect boss key.
Disable Your Touchpad While Typing
Combine AutoHotkey and Dropbox to Monitor and Control Your PC Remotely
If you’re a Dropbox user, you’ve probably already found many clever ways to use Dropbox, but combined with AutoHotkey you can really do some interesting things, like monitoring your PC or launching applications remotely.
To monitor your PC remotely, you can simply create a script that triggers a screenshot utility in the background every few minutes — by simulating pressing the shortcut key that the utility is assigned to. For instance, if you are using the simple Screen Grabber utility, this script would press the Shift+F10 shortcut key every five minutes. You can alternatively check out the full guide over at Digitial Inspiration, along with a downloadable version of the script.
If all you really want to do is launch an application on the remote PC, you can create an AutoHotkey script that runs and then reloads itself every five minutes — so you can add a line to the beginning of the file, and the next time the script reloads it will run that line. Since the script is sitting in your Dropbox folder, you can edit it from anywhere.
Run, C:Program FilesLogMeInx86LogMeIn.exe
In the example script, the top line wouldn’t be there normally — that’s the line that you can add from anywhere to launch the application. Once it’s been launched, you can remove the line from the script so it won’t launch again. Check out the rest of the instructions in our guide to launching applications remotely with Dropbox and AutoHotkey.
Search Google from Any Application
If you’re tired of copying and pasting from one application into your browser’s search box, there’s a much simpler way to go about this that works no matter what application you’re in — just create a simple AutoHotkey script to map the Ctrl+Shift+C shortcut key to automate copying the text to the clipboard, and then open your default web browser with a Google search for the selected text.
Shorten URLs with a Shortcut Key
If you spend a lot of time on the social web, you’ll probably need to shorten links on a fairly regular basis, and while most Twitter clients support short URLs natively, if you aren’t using a client or just want to shorten a URL to use somewhere else, you can easily setup an AutoHotkey script to generate a short URL with a shortcut key. The script essentially automates the process of creating a short URL using bit.ly by taking the URL off the clipboard, creating a new tab in your browser that generates the short URL and copies it to your clipboard.
Make Your Caps Lock Key More Useful
Use Your Caps Lock Key as a Navigation Tool: You’ve got numerous options, but perhaps the most interesting one is to turn the caps lock key into a hand-friendly text navigation tool — essentially, you hold down the caps lock key while using other keys like J, K or L to move the cursor left, right, up or down — there’s a whole slew of different keys in the script and you can customise it as much as you want.
Minimise Active Windows with Caps Lock: If that’s a little more than you want to deal with, you can turn your Caps lock key into a dedicated minimise button with this simple script, which minimises the active window whenever you hit the Caps lock key:
What are your favourite AutoHotkey scripts and techniques? Share your expertise with your fellow readers in the comments.