AutoHotkey scripts for translators

I’ve always had a secret desire to be able to program computers… the problem is it’s not something you can do just like that!  I can recall starting off with a Commodore PET 2001 some time in the late 70’s and I can remember how enjoyable it was to be able to create simple scripts that could react to whatever you pressed on the keyboard.  I should have realised back then it would have been smart to focus on technology, but instead I took a bit of a detour in my career and computers didn’t feature at all until around 1987 when I was introduced to the HP41c from Hewlett Packard.  This had very basic programming functions, a magnetic card reader and a thermal printer and I loved it!  In fact I loved the way HP calculators worked so much I had an 11c for years until I dropped it trying to align a laser while being dangled headfirst into a catchpit on a construction site!  And we think the Studio alignment process is tricky 😉

But that’s another story… what I’m slowly getting to is the ability to program computers to make them behave the way you would like.  Today, programming computers requires a lot more technical knowledge than it did when I was writing small applications for a PET or an HP calculator.  But fortunately for me this doesn’t mean you can’t use the same sort of scripting skills that I used in the “olden days”.  The advent of APIs support the work of clever developers who have created tools such as AutoHotkey or AutoIt that can allow people like me to write a simple script that can interact with a modern windows computer, or even a modern application running on that computer.

One of the more popular tools we see for this is AutoHotkey and I have written an article in the past explaining how to use this for autocorrect in any application at all.  I have also suggested to users that they try AutoHotkey to resolve things from time to time that cannot be done with SDL Trados software without a series of manual steps.  For example, if you wanted to merge segments you would have to do this:

  • select the first segment
  • select the second segment
  • right click and merge segments (or use keyboard shortcut, default is Ctrl+Alt+S)

An AutoHotkey script can automate these three steps so you only need a single shortcut.  The script might look like this:

^m::
Send !{Space}
Send !{Down}
Send !{Space}
Send ^!s
Return

This basically means you can use Ctrl+M to merge the segments and that’s it!  All the script is doing is mirroring the manual steps you could use via the keyboard, so this:

Alt+Spacebar
Alt+downarrow
Alt+Spacebar
Ctrl+Alt+S

The simple things to know in this script are these:

^    =   Ctrl key
!     =   Alt key
{Space}    =    Spacebar
{Down}     =    Downarrow

Pretty straightforward isn’t it?  The Send command just tells your computer to carry out the command after it.  These sort of commands are called hotkeys and you can find great information on them in the AutoHotkey site.

There are even more simple applications for these scripts.  For example, I have a UK keyboard but I speak to people all over the world with some very exotic (for me) names.  So I have a very simple script setup that corrects the names for me in any application I’m using at all.  The script looks something like this (only much longer!):

::Andraz::Andraž
::Asbjorn::Asbjørn
::Aysan::Ayşan
::Balazs::Balázs
::Boguslaw::Bogusław
::Cetin::Çetin
::Darek::DArek
::Laszlo::László

Nothing complicated about this either but it means I can always write peoples names correctly… which I like to do.  The way it works is I type the name to the left of the double colon and the name after the double colon is what’s actually rendered onto my screen.  If I come across someone new with a tricky name I just add them to the list!

This list sits in a text file with the extension ahk somewhere on my laptop.  I can use this same file on any computer I have which has AutoHotkey installed and whenever I come across a new and interesting script from somewhere I can just add it to the text already in the file.  So very very straightforward and easy to use.

In fact I like these scripts so much that we created an AutoHotkey forum in the SDL TP Community yesterday so we could use it as a resource for people to find and share scripts that are useful for them.  We’re already finding a number of really useful scripts appearing and I hope the list is going to increase over time.  What do I mean by really useful… things like these:

  • quick google lookup of selected text
  • change segment to uppercase
  • merge adjacent segments
  • provide a character count of any selected text (even across segments)
  • add tags with a single keystroke
  • remove AT statuses as you work
  • use headline style capitalisation for titles
  • copy source fragment target

All of these things can of course be done without AutoHotkey… but not in a single keystroke!

The other very useful thing to note is that there is also an AutoHotkey Forum set up by themselves and in there you probably have access to thousands of users who are skilled with creating scripts for all kinds of things.  So even more help is never far away!  I’m looking forward to seeing what sort of things turn up in the SDL Community in the meantime because this is also a very good indication of the sort of things users need to be able to do that would make their use of the software a lot more productive than it is already!

2 comments
  1. Nora Díaz said:

    Having the forum is a great idea, Paul. AutoHotkey is one of those things I wish I had started using earlier. I made several false starts because I couldn’t find a good beginner’s guide and it all looked too complicated, the amount of information out there can seem overwhelming to a newbie, but once I made up my mind I realized it wasn’t all that hard after all. I still wish I really knew how to use the more complicated features, but my very basic knowledge has been useful so far to write macros that speed up my work in Studio and other programs, and now with the library that will be built by the Community on the new forum, I’m sure I’ll find many more helpful scripts.

    Like

    • Thanks Nora… I feel very much the way you do. Probably need to devote some evening time to working through the tutorials and examples around the autohotkey site!

      Like

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

%d bloggers like this: