This post carries on from this series from a couple of weeks ago:
- Adding a global keyword menu to AutoCAD using WPF – Part 1
- Adding a global keyword menu to AutoCAD using WPF – Part 2
- Enabling global commands on localized AutoCAD versions using .NET
The overall goal behind these posts was to create a “command-line helper” tool to make it easier for people who know the English version of AutoCAD (or an AutoCAD-based vertical) to work with a corresponding localized version. Basically because some people learn AutoCAD using an English version – perhaps during their studies – but then become a bit lost when they find they suddenly have to work with a local-language version in a professional setting.
In previous posts we’ve added the ability to launch global commands without the underscore prefix (we check for “unknown commands” and try them again with the prefix) as well as displaying a helpful “global keyword list” dialog while commands prompt for keywords. Here’s a reminder of what this dialog looks like:
Which is a good start, but the next big hurdle was around entering global keywords without the underscore: it’s all well and good to be able to launch a global command via the command-line, but if you then have to double-click a UI element to enter a global keyword (or remember to add your own underscore prefix when typing it yourself) then it’s incomplete.
I spent much of today adding global keyword support into the command-line: what we wanted to do was insert an underscore prefix in front of a complete keyword being typed in at the command-line assuming it matches an expected global keyword (of which we handily already have a list in our popup dialog).
I wasn’t at all sure this was possible, I have to say. My thinking was to use the powerful-but-scary Application.PreTranslateMessage event – which I talked out many moons ago – as this gives you really low level access to messages arriving via the input pipeline. But I wasn’t at all sure it would give you the access you need to achieve this.
It did turn out to be possible – as of about 30 minutes ago I managed to get something working – but there’s quite a bit of code I need to tidy up before posting. We’ll take a look at the solution either tomorrow or the day after. Watch this space!