Stifel's Audiobooks Blog

Tech Tips and Opinions for the Audiobook Community

Month: August, 2014

Using Keyboard Macros Part 2 – AutoHotKey

Using Keyboard Macros Pt. 2

AutoHotKey

So how the heck do you create these keyboard macros? You can’t do it just with Windows, nor with a Mac – that functionality is not included in either operating system. You need to acquire a keyboard macro program. For Windows, this is a piece of freeware, available at www.autohotkey.com/download . (The freeware status of this program has apparently caused some rifts with the developers. There is now a www.ahkscript.org claiming to be the definitive and newest version of this program. Caveat emptor – I am currently running version 1.0.48.05, the one you can download from www.autohotkey.com/download .)

Let me reiterate here, this part of the series relates to all Windows users. Even if you don’t use the same DAW as I do (Sony Sound Forge), the software I’m talking about today will work on any of the DAW platforms you may be using.

As for Mac users, do a web search on “keyboard macros for Mac” to see what utilities are available for you to use. Though the exact syntax will differ, the concepts and general approaches I describe will – hopefully – translate to both PCs and Macs.

So, you web surf to www.autohotkey.com/download, and download the install program. Simply double click on it once you’ve downloaded it to initiate the installation. Should be very quick.

The online documentation for AutoHotKey is valuable and pretty extensive. If you are really motivated, by all means read through it for a much fuller account of this utility. For now I want to describe the high level operation, since the documentation can be too much of a good thing if you are just beginning.

What have you done exactly by “installing” AutoHotKey? This program is now running along with Windows every time you boot up until you power down. It will not show up in your task bar. It will show up as a process in the Task Manager. The program is simply sitting in memory, waiting for you to tell it to do something. Until you do, you’d never know it was there.

The way you tell AutoHotKey to do something is to create what we call a command script, or command file. You could use a fancy word processor for this, but only if it lets you save files as text only. The formatting information in complex word processor files will completely confuse AutoHotKey and make a mess of things. Best to just use Wordpad to create and edit command scripts – and be sure to save as text only!

The command file you create with Wordpad may be named anything you wish, but the file extension, the last three characters of the file name following a period MUST be .ahk. Filename.ahk. Anyname.ahk. Once you’ve saved this file, you find it in Windows Explorer, or paste a copy to your desktop. Double clicking activates it. Just like any program, you double click on this file name to wake AutoHotKey up – the ahk extension is how AutoHotKey knows to read this file and do something with it.

You can tell if any scripts are active by checking the Windows taskbar. An active script (you can run more than one at a time) shows up as a green icon with a capital H in the center. You can right click this icon from the task bar to edit that script, pause the script (ignore it temporarily), or exit – wipe the script from memory so that it is no longer active at all.

AutoHotKey Scripts – Bare Basics

An AutoHotKey script does two things:

 

  1. Identifies the keyboard keys that you want to take over and give extended (or diminished) functionality to.
  2. Tells AutoHotkey when it gets one of these re-defined keystrokes, what to do with it and what commands to send down in place of that keystroke.

Let’s start with a real, simple but nontrivial example. Let’s say I want to completely turn off the F9 key.

Your script to do this would look like this:

F9::

return

The F9 is a “standard” key name understood by AutoHotKey. The two colons :: signify “Here follows a definition for the preceeding key.” The “return” is a built in command understood by AutoHotKey to mean do nothing more, you’re finished for this key. That little chunk of code will disable the F9 key (stay tuned for why anyone would want to do that in the first place. I have a danged good reason.)

So you type those two lines into Wordpad, you save the file as text only and give it the name “DeadF9.ahk”. Now when you double click on DeadF9.ahk, the F9 key will indeed be completely dead. It will continue to be dead until you reboot your computer, or you can exit the script by right clicking it from the task bar. You only need to activate a script once. If you try to activate it a second time, AutoHotKey will tell you it’s already running, do you want to run two copies (I have not yet found a situation where that would be useful.)

A few more conventions for scripts. You would seldom want to change the meanings of any of the alphanumeric keys on the keyboard, nor would I recommend redefining any of the punctuation keys. The ones I use consistently are control-key combinations, alt-key combos, and function keys. Such well known combinations as Ctl-C to copy, Ctl-X to cut, and Ctl-V to paste – these functions are so ubiquitous, I would not recommend redefining them either.

But stuff like CTL-U, CTL-I, Alt-M – stuff that is not universally used by Windows is fair game. In your command script, such keys are shown with a carat ^ to indicate the control key, followed by the alphabetic key. Thus Ctl-u in the AutoHotKey script would say:

^u::                              ; redefine Ctl u

And here’s another useful feature – see the semicolon in that line? The semicolon in command scripts means that AutoHotKey will ignore the semicolon to the end of the line – it is not a command for AutoHotKey, it is a helpful comment to describe in English what’s going on. It’s what programmers call self-documenting code. Use this feature liberally – scripts can get involved and hairy real fast. Leave bread crumbs to tell yourself what you’re doing.

FYI the shorthand for the Alt key is the exclamation point ! – !m would mean the Alt-m combination. The function keys are a piece of cake F1, F2, F3 etc.

A number of special keys have internal definitions, and are specified with curly braces enclosing the keyname. {Enter} = the enter key, {Tab} = the tab key, {NumPadDown} = the down arrow on the numeric pad. (See why I recommend reading the documentation? There’s far too much to cover here, I’m just trying to give you the flavor, and the basic stuff you’ll need to understand the coming examples.)

Okay, absorb this information and get ready for the next installment. I will show you a command script that will let you paste room tone over any mouse selected area in Sound Forge – with a single keypress. This makes covering a selected area with room tone just as simple as zeroing it out – except the room tone will get you past QA, and zeroing it out won’t.

Coming next in Part 3: One keystroke to cover selected area with room tone.

© 2014 David Stifel – All Rights reserved

 

Using Keyboard Macros – Part 1

Welcome to my blog!

This is the first in what I hope to be a series of useful and thought provoking posts to the audiobook world. I’ve found the online presence of narrators and producers who hang out in the ethersphere together to be the most genial bunch of good hearted people I’ve ever found. And I want to give back to this community.

So I’ll be offering tech tips, advice, curmudgeonly opinion stuff that’s too long to fit comfortably into the social media platformsall’s fair game as long as it’s audiobook related. For starters, I’m going to do a series on keyboard macros and why the heck you narrators, editors and producers should care about them!

Using Keyboard Macros Pt. 1

Most of you have heard about keyboard macros. And that’s about the extent of it.

What every one needs to hear is that “Keyboard Macros are an invaluable productivity tool for those of us who do any editing to their sound files.”

Okay. So what is a “keyboard macro” anyway? A keyboard macro is variable list of keyboard (and/or mouse) commands, defined by you, that accomplishes complex tasks with a single keystroke. Let’s take a really simple example – padding the front of an audio file with a half second of room tone – and only a half second of room tone.

Normally you’d do something like this:

  1. Put your cursor right before the start of the first sound in the file.
  2. Delete everything from the cursor to the beginning of the file (eliminating all the existing room tone at start of file, because its duration is not known.)
  3. Go to another file that contains pure room tone of several seconds duration.
  4. Copy exactly a half second of this room tone file.
  5. Go back to your first track and paste the half second of room tone where the cursor sits.

Simple, really. But note how many keystrokes and mouse clicks it takes to accomplish this. Numbers 1 and 2 above are pretty simple mouse actions. Number 3 could involve bringing up a file menu, selecting “Open” on that menu, navigating with the keyboard and mouse to where the room tone file lives, opening it. NOW – set a start point in the room tone file, use keyboard commands to select exactly a half second duration. Keyboard command for copy. Keyboard command to go back to main file. Keyboard command to paste current clipboard contents into the audio file at the cursor.

Not too bad, really, until you consider you do this a lot of times when editing a sound file, don’t you? You need to insert a half second of room tone at file start – you need to insert 2.5 seconds between chapter headings and narration, and 3.5 seconds at file end. A half second of room tone is really useful for pasting into the file when you want a little more time between sentences, or paragraphs. Sometimes you’d like to fine tune your timing like this but the repetitive keystrokes and mouse commands get so tedious you say, “Naw, it’s good enough. This is taking too much time”

What would it be like if you could tell your computer, “Every time I hit the F12 key (I never use it for anything else anyway), I want you to insert exactly a half second of room tone into my file at the current cursor position.” Wouldn’t that start to make life easier, and your throughput a lot faster?

That’s exactly what a keyboard macro does for you. It strings together combinations of keyboard commands and mouse actions to accomplish complex tasks with single keystrokes.

So I will be blogging over the next few weeks about some useful keyboard macros I use that may help you grease your editing throughput. Here are the assumptions:

I work in a Windows (XP and 7) environment with Sony Sound Forge Audio Studio 10 as my DAW. The code examples I will give will be specifically for these tools – but I hope to write generally enough for Mac users and non-Sony users to be able to take this information and apply it to their own situations intelligently.

Coming next in Part 2: AutoHotKey – a tool that lets you create your own keyboard macros.

© 2014 David Stifel – All Rights reserved