Wow… how time flies! Over three years ago I wrote an article called AutoCorrect… for everything! which explained how to use AutoHotkey so you had a similar functionality to Microsoft Word for autocorrect, except it worked in all your windows applications. This was, and still is, pretty cool I think and I still use autohotkey today for many things, and not just autocorrect. Since writing that article we released Studio 2015, and in fact Studio 2017 is just around the corner, so it was a while back and some things have moved on. For example, Studio 2015 introduced an autocorrect feature into Studio which meant things should be easier for all Studio users, especially if they had not come across autohotkey before.
At least I thought it would be easier! I was reminded yesterday with a comment to my earlier article that if you wanted to edit and maintain the autocorrect list somewhere else, somewhere it might be more accessible then the process is not so simple. Yes there is a import/export feature for autocorrect which you can find here:
But this list is not a simple text file… rather it’s XML. This of course is not insurmountable, but it’s not immediately obvious as the comment to my previous article made clear. So here’s one way to tackle it using regular expressions and excel. I used this combination because after playing around with excel for a little while I realised that getting the word lists from the XML was far easier with regular expressions, whilst reconstructing the XML from Excel was a fairly simple task. So one more reason to learn a little more about how to use regular expressions!
I have created a 14 minute video below that covers the whole process from start to finish. But for those of you who just want a hint, or just want to check whether this is new to you or not, here’s what I did in a nutshell:
What we needed to get from the XML?
When you export the autocorrect file from Studio you will have a number of entries like this which you’d really rather have as text without the XML syntax:
All the autocorrect entries sit between the <AutoCorrectEntries> node. The text you’re interested in is inside the attribute entries for the incorrect entry, src=“abbout”, and the correct entry, trg=“about”. The easiest way I found to get these as simple text entries was to use regular expressions which you can apply in Notepad++, or EditPad which I use for example. So I searched for this (slightly different in the video as I used \s here in case you wanted to copy paste and didn’t realise you needed the spaces at the start, which you do):
\s\s\s\s\s\s<Entry src="(.*?)" trg="(.*?)" />
Then replaced with:
This gave me the “incorrect entries” as a list. I then undid the results of the search replace operation and immediately searched again with:
That gave me the “corrected” entries. I pasted them both into excel so now I have something like the image on the left with a separate column for each entry in the autocorrect list.
That’s it for the regular expression part… pretty straightforward I think but if you want to learn a little more there are plenty of resources available on the web in addition to a few articles I’ve written in the past specifically on the use of regular expressions for Studio. It might be helpful to see where you can use these sorts of techniques in Studio if you need more of an incentive to learn.
So now you have your Excel spreadsheet which you can use to add/edit/amend the entries as you see fit.
What we have to do to get the Excel back into XML?
The task now, once you’re ready to re-import your Excel into the autocorrect settings in Studio, is to get your XML syntax back. So to do this I just laid the Excel sheet out like this:
This is all text. Note that my autocorrect entries are now in column B and D. The other columns contain the syntax that makes up this line in XML:
<Entry src=“abbout“ trg=“about“ />
To put this back together I just concatenated the cells with this expression in cell G1:
Looks complicated but it’s actually very simple as you’ll see in the video. I can copy this formula down the spreadsheet and I then have all the text items expressed in the correct XML syntax so they can be copied back into the XML file. It’s a good idea to keep a copy of the original XML export and don’t mess around with that just in case you break something and can’t import your entries back in, or corrupt the autocorrect file itself.
That’s it, not too tricky, and it will allow you to work on your autocorrect entries in a more productive environment than one at a time in Studio. The full end to end process is in the video below… hope this is useful!!