Pressing keys quickly (and more!) with AutoHotkey


Why can’t you copy the Voyager bib number for reliable pasting into email and other records? I can do it now, along with a million other little things, using AutoHotkey macros.


The (First) Problem

Cataloging in Voyager, I did a fair amount of grumbling because I couldn’t copy the bib number of record I was working on. The need came up almost every day: I needed to paste it somewhere to overlay or relink records, create a boundwith, pull up that record quickly in the opac, or just email it to a fellow cataloger to ask about the record. Sometimes I did this in an analog way, like trying to remember the seven digits in my head, hoping nobody would speak to me before I could retype them, or scribbling them on a piece of paper I kept on my desk for just that purpose. I had a few shady digital solutions where I’d type it into a small text file while I could still see it on the Voyager screen, and then copy and paste it from there to where I needed it. We all had our own workarounds for this obviously missing feature, and we still did enough bad overlays to prompt me to speed up the ensuing record recovery. I always felt silly, too, since the equivalent task is so easy in Connexion — you just copy and paste!


At some point, I discovered that the bib number was directly available for copying and pasting, under the File -> Print Label menu (no hotkey), and I did it this way only a few times before I was determined to make a macro to do it for me.


AutoHotkeyAutoHotkey is a free, open-source macro utility for Windows. It can perform the actions of a keyboard and mouse (even a mouse with extra fancy buttons) and display dialog boxes with blanks and buttons to control the actions of the script. It has a macro-recorder, though I haven’t used it; macros in its scripting language are relatively easy to read and adapt to your own purposes. Macros can be distributed as text (.ahk) programs for users with AutoHotkey installed, or as binary executable (.exe) files for users who just want to run them. The documentation on the web site is very helpful, and the forums are active.

The development cycle for macros is reasonably quick. Once you have a macro running, it appears as a small green box with an H in your system tray. To edit the macro, you can right-click that H to open the macro code in Notepad.


After code has been modified and saved, the macro can be re-loaded (so the new version is running) from that same menu.

First draft

My first AutoHotkey macro solved the problem of capturing the bib number, using the Print Label function. It did something like this:

  • Confirm that I am running Voyager
  • Open the Print Label menu
  • Wait briefly
  • Scoot scoot scoot until you get to the bib number
  • Hold down Shift, press End, then let Shift up (this will highlight the whole line)
  • Hit ^C to copy
  • Hit Esc to close the window

This worked pretty well, but had a number of problems:

  • The first label of the day (?) was always slow to appear; the brief waiting time was never long enough that first time, but worked every subsequent time. To keep the macro fast, the instructions were to just run it twice the first time you used it that day.
  • The amount of scooting needed is user-dependent, as the fields in the label (and thus the number that need scooting past) is configurable. Not an issue at my site, since we all had the same configuration, but made me wary of distribution.
  • The copied number had extra space at the end, which sometimes mattered. I added code to trim this.
  • The macro dutifully pressed all of its buttons no matter what kind of record you had open in Voyager, so that was sometimes weird. No harm done though.

Though the macro wasn’t perfect, it was good enough, and we ran this for months while I wrote more macros, and learned more about the language. It was a massive improvement over the old methods. This version of the macro is still available on GitHub as a stand-alone program, and as a subroutine of its new improved version.

Text replacement

Another common use of AutoHotkey is hotstrings or automatic text replacement; that is, if you type this specified string of characters (configurably followed by an ending character like whitespace), it will be erased and replaced by another string of characters. For many people, this is handy for expansion of abbreviations (“btw” -> “by the way”) or correction of typos (“taht” => “that”). In cataloging, I have found them useful for several other types of tasks.

The first of these is for characters that are hard to type. Many RDA records contain a copyright symbol in the 260 or 264. The rules allow for typing the word “copyright” instead of using the symbol, but I haven’t seen one of those in the wild yet. The symbol can be dug up in Connexion from the Edit->Enter Diacritics window, or typed directly from your keyboard if you remember the unicode code point, but neither of these options are compelling. You can instead do a hotstring macro, so that any time you type (c) it will be replaced with © :

; easily type copyright symbol

A similar macro can be made for the phonogram symbol:

; easily type phonogram symbol

We have used a similar macro so that we can use the same key to type subfield indicators in Connexion and Voyager. Since Voyager goes into confusing “Diacritic Mapping Mode” with Ctrl-D, we intercepted that behavior and made it type the subfield indicator instead. (Remember, if you are intercepting a hotkey in just one program, it is polite to pass it through so others can still use it!)

Hotstrings are also useful for text that must be typed often. Why type “Includes bibliographical references (p.) and index.” and risk spelling bibliographical wrong, when you can type the shorter brn and have it expanded?

; 504 template
::brn::Includes bibliographical references (p. ) and index.

CoLibriIt’s easy to go a little crazy with hotkeys and hotstrings, though. The danger becomes twofold: you may not remember all of the shortcuts you made and end up typing the full versions anyway, or you may type your shortcuts accidentally in the regular course of typing.  I nearly made that hotstring “bri” before remembering that we just got a CoLibri book covering system, which would have made for some interesting emails.

I can remember a lot of brief character combinations (In Voyager, alt r-p-n selects a new export file, and alt r-p-v opens the previous!) but I expect there are limits.

Dialog Box Options

If your desire for quickly typing strings outgrows your memory and available keyboard shortcuts, you can build a menu from which they can be selected. For example, we purchase books for the library using a number of funds, and include their information as a note in the bibliographical record. Rather than typing these in each time (or having each staff member maintain their own sheet to copy and paste from) we could have these available centrally as a macro where choosing a button (with mouse or shortcut) enters the correct donor note:


I am still cleaning up this code, but will make it available when I’m happier with it.

New Version of Bib Capture

After having written more macros, I revisited the Bib Capture macro, and improved it, so that it now does the following:

  • Confirm that I am running Voyager
  • If possible, extract the bib number from the window title (works in Bib and Mfhd records)
  • If in an item record, extract the bib number with the old method
  • Pop up a message box indicating the extracted bib number (closes after 1 second)

This version works every time (so far!), only in records where it should, and is mostly not dependent on the user’s label setup (except if you wish to capture the bib number from the item record screen). A few similar macros I have written:

  • Capture the MFHD number
  • Capture the Item number
  • Capture the Authority record number
  • Capture the RECORD number of the open record, regardless of its type

That last one is probably the one that will be most useful to me, but that doesn’t seem like a reason not to share the others.

The Code

Code for my macros is available from my GitHub repository. Scripts specific to Voyager are in the Voyager repository, and others are in my AutoHotkey repository.

To get started running macros, download and install AutoHotkey. Depending on your setup, you may need administrator permission. Another option is to have one person in your group install and build the macros, and distribute an executable file to everyone who wants to use it.

AutoHotkey macro code is contained in text files with a .ahk extension, so you can edit them with any text editor. You can easily build your macro file by saving one of my .ahk macro files from the repository under a new name (MyMacros.ahk or so), and adding the text from other .ahk files to the bottom. You can also modify according to your preferences, or write brand new ones!

Once the file is created, you can run it by double-clicking it (or right-clicking and choosing Run Script). You can also compile the script by right-clicking and choosing Compile Script, which will generate a .exe file that can be run by anybody.

To make the macro available to you all of the time, you can set it up to start every time you login by adding it to the Startup folder in your Start Menu. To do this:

  • Click the Start button, then click All Programs and locate the Startup folder.
  • Right-click the Startup folder and choose Open.
  • Copy and paste the file .exe or .ahk file into the Startup folder.

More macros?

Have you written macros to drive Voyager? Did you use AutoHotkey or some other system?

Do you have ideas for more macros? I’d love to hear from you! (What else are you tired of typing?)