in random, web design

Macro Man!

This is a long techy post but don’t click ‘next’ just yet! it could make your working life a hell of a lot easier.

You know computers are supposed to make your working life easier not harder right? But it can be easy to forget that sometimes, and some people will downright deny it! We’ve all had moments where we wanted to drop a PC out of a high story building but in general day-to-day work, if your computer is making your life harder, there’s a good chance you’re just not using the right tools. Or you’re not using a fraction of their potential. And that potential is to make your life much easier.

For every repetitive task you do, you could probably be using a dedicated application, an automated function or a macro. Some tasks are so suitable to this, that you can click a button and just watch your computer working away for a minute, doing a task that previously took you 15 minutes by hand. 15 long minutes of grunting and swearing and banging the keyboard.

Macros

One of the greatest labour-saving devices in computing is the macro. A simple definition of a macro is the ability to record your keyboard and/or mouse actions, so you can ‘replay’ the actions rather than manually redoing them each time.

I first got into the whole macro thing when I started a job as a technical writer where we were using Word to write our documents; scripts for content developers and voice over artists. All the text had to be in very particular formats, labels, layouts and colour-codes. People spent an unbelievable amount of time on the formatting rather than the actual writing. Word Styles (which looked different on every computer were driving people crazy). They spent a fortune getting some guys to build a dedicated application but that was just as bad. An unfortunate but all too frequent case of programmers with no user interface skills building a useability nightmare. So I dug a bit into Word’s automation and customization and it ended up as the perfect solution.

People slag off Microsoft products – but the level of customization you can do in Word makes it an amazing piece of user centred software. You can record your own macros, then create keyboard shortcuts or buttons to trigger the macros and you can add whole toolbars containing the buttons, or use menus to add new commands. You can also delve a bit deeper with vbscript to add loops and if statements to your macros, almost building applications within the application.

I started off recording simple macros for myself that would make text red bold, green italic etc. Then I would map that to a keyboard shortcut. Then I started adding more complex functionality. I started sharing these with the team and soon enough I took on the role of completely redesigning all the templates, and processes used throughout the whole production team, making use of every level of automation available. I got really carried away with the macros then, using them to build whole tables of information.

The main template ended up with a whole toolbar of buttons, a customized insert menu, and lots of other functionality available through keyboard shortcuts.

Below is a brief video example: At the click of a button, a whole table is split up, formatted and populated. Common phrases are added from the insert menu. That’s just one type of table, we had about 5 different types, all added with one click. At the end of the process, another macro re-formatted the whole script to spit out xml for the developers and a vo script for the voice over artist.

This is an advanced version of the amount of work you can save yourself doing if you use Word a lot and find yourself doing any task again and again.

I didn’t intend to write this as a tutorial, more as a nudge in the right direction, but let’s have a quick go. We’ll create a copyright type sign off.

Step1. Record the macro

  1. In Word, go to Tools > Macro > Record New Macro > Type sig then hit Enter
  2. Go to Insert > Symbol > click the Copyright symbol > Click Insert then Close
  3. Type a space, then your name, then another space
  4. Go to Insert > Date and Time > Click OK > hit enter to go onto next line
  5. Click the square stop button on the macro toolbar

Step2. Make a button

  1. Go to Tools > Customize > Commands tab
  2. Scroll down on the left column and click Macros
  3. Your sig macro will be on the right, click-and-drag it to your toolbar (beside the bold button for example)
  4. Now right-click this button (don’t close the Customize dialog box) and select Default Style
  5. Then right-click it again and select Change Button Image and select the pencil icon (You can also right-click and edit these icons and make your own)
  6. Close the dialog box.

Step3: test it out

  1. Click the pencil icon
  2. Click it again!
  3. Cool hoh!?

You can record any kind of macro you want. Very detailed ones. Though beware you can’t just click all over the screen, you have to use your keyboard to highlight text and navigate around text. Find and replace type macros can be very useful too. I have a few macros that I use now to take a word document and clean it up for the web, so it replaces foreign characters and symbols with the proper Unicode / html.

When I was leaving the job where I built all the macros, I was handed a thoughtful customized gift that is one of my proudest possessions: a Macro Man superhero t-shirt! It even has the buttons on the back!

Breaking out of Word

Right so. Word Macros. Great craic altogether. Used wisely they will save you a lot of work. Invest a bit and you get a lot – but what about outside of Word? Now you need an independent macro recorder. I’ve tried a few over the years but recently found one I really like, autohotkey, a free, open source application. Downloadable from http://www.autohotkey.com/

Autohotkey, lets you record mouse clicks and keyboard actions. That simple. You can use it in a number of ways. It’s one of those programs where the more you invest in, the more you get back. I found, I really needed it a few times recently. It was a total lifesaver. If you find yourself cursing a really badly designed user interface, something like autohotkey can make all the difference.

I was working on a job recently where I was migrating from one web based resource centre to another. I had to add loads of images. Three versions of the same image every time. The UI and UX design was terrible. I had to browse through a load of folders every single time I needed to add an image, it took about 5 minutes and 50 clicks to add every image! After recording a few macros in autohotkey, I could just sit there with my arms folded and watch autohotkey do all the work. It’s great to watch!

Below is a video capture of another resource library that I used regularly, and went to the same location regularly. I often had to login and browse through lots of folders ever time, clicking those tiny plus symbols (which should be banned from all user interfaces!). The video below isn’t impressive in itself but bear in mind that I just pressed a button, sat back and watched until the folder with the images I wanted was open.

Autohotkey comes with a recorder but you usually have to edit the script a bit as well. It doesn’t record intervals between actions, so you have to add a lot of pauses, or sleeps. It’s very easy script to edit though. Here’s one example:

Send, {ALTDOWN}{ALTUP}fd

sleep, 2500

Send, {ENTER}

What this does is press ALT F D on my keyboard, waits 2½ seconds, and then hits Enter. When I’m using Photoshop, I run this script with a keyboard shortcut and it goes to ‘save the image for the web’. Something that you do a LOT, yet takes longer than it should; a good simple example of using Autohotkey.

Another example is when I’m editing PHP that has to be previewed on a live server. That’s a lot of clicking for every edit. Now I just press a button, and Autohotkey saves the file (in dreamweaver), uploads it, waits a tiny bit, then switches to Firefox and hits refresh. So much easier. And I had it set up in now time.

You can also use Autohotkey to autofinish phrases that you type a lot. For example when I type JBA, autohotkey types my name and address and when I type btw, autohotkey types by the way for me. Again you can see that investing a bit of time here, could save a huge amount of time in the future. Word has an inbuilt version of this too, called autocomplete but obviously autohotkey works throughout all applications, so you can use it for webmail, twitter, excel… whatever.

A launcher

The final part in automating your work easily is to have a dedicated launcher for your macros. You can launch Autohotkey macros as you would any other file; by adding a desktop shortcut, or adding an icon to your taskbar, or using a keyboard shortcut but the snazziest method of all is to buy a dedicated programmable keypad. This really ties everything in together nicely. After much research I got an X-keys desktop. It’s got 20 programmable keys. Setting it up couldn’t be easier, it’s got a great interface, you just click a switch on the hardware and the buttons appear onscreen, then you can drag your shortcuts onto the keys and flick the switch again. It’s also got its own Macro software that’s also really easy to use but I mostly use Autohotkey.

X-Keys comes pre-programmed with regular functions like cut, copy, paste and undo, which I’d recommend keeping. It also has shortcuts to launch applications like your browser or email but I think this is a terrible waste of hotkeys. Any application that you open and leave open for most of the day is a waste of a key.

You can save different presets with the x-keys software, so you can have a whole keypad of different shortcuts just for Photoshop, or you can load another full of html code, and another for general use. But as they keys are labelled with stickers, if you change the presets a lot, you have to remember or write down the combinations. I haven’t properly labelled them yet as I’m still changing them a lot. One idea I find useful is to have one key mapped to an autohotkey script called ‘latest’, which will launch whatever macro you’re currently using a lot.

It was very hard to find somewhere I could buy this from Ireland. I eventually got it from Keytools. You can’t use the web form to buy directly from Ireland but you can ask them to fax or email you a form.

I was also going to write about various applications for very specific jobs but this post is already big enough, but just to point you in the right direction, there are applications for everything these days. If you find yourself resizing windows to specific dimensions a lot, then google ‘windows resizer’, if you find yourself taking lots of screen grabs and emailing them to people then download an application to do it for you. Or just have a look around download.com or tucows or lifehacker for some inspiration.

So – I’ll say it again: invest a little and you will get a lot back, stop banging your head against your computer screen, give it a big hug instead!

Write a Comment

Comment

  1. John, you’re a genius. You’re a genius. You’re a genius. And so am I, for being so clever as to always read your blog.

    Since reading yesterday morning, I now have a button in Excel where I keep customer lists, that launches a script I wrote with autohotkey, that launches IE, browses to our RMA outsourcers website (which was coded by a 3-day old monkey high on crack), waits till it loads, logs me in, and then selects the raftload of options you have to select every time you log in, then pastes the customers number from the clipboard (copied in excel before running the script), and then calls up the details, and leaves you on the right page to finish the RMA. And I’ve only just started.

    You are a genius! Cheers!

  2. Thanks for the feedback guys. Thought it might be one of those long posts that people don’t bother reading.

    Dave you’ve surely brightened my day 🙂 Great to watch it at work innit? I reckon it’s the Autohotkey people that are the genii though.

    Cheers!
    J.