Using AutoIT to Enhance the User Experience

As a long time Engineer at PTC I have always had many installations of Pro/E on my system. I also have to work with many different companies, meaning many different and files. In fact starting Pro/E with the right set of configs can be a hurdle in itself. On one project I had the fortune to be requested to help develop some scripts using the AutoIT scripting toolset. This open source scripting language allows people to quickly write an application to essentially put a front-end onto batch files. This article demonstrates how a little AutoIT magic and the concept of Simple Automation can produce an application to help me pick the right Pro/E and Configs to start up with.

The Choices

What this article shows could be acheived with Java, C/C++, Visual Basic. You could even achieve the same result using a clever batch file (albeit without the nice front-end). However I chose to show you how this can be done using the AutoIT toolset as I am extremely impressed with it from the perspectives of a)Simplicity b)Power c)Clarity of documentation and d)Cost.

I am choosing to show you how this can be done using the AutoIT toolset.


Desired Feature List

I chose to aim towards the following features when I started out.

  • Need to be able to centrally capture all the ProE Versions I use.
  • Need to be able to centrally capture all the's I use.
  • Need to be able to centrally capture all the's I use.
  • Need to be able to centrally capture all the Mapkey files I use.
  • Wanted ability to capture my preferences as defaults for when the app started.
  • Wanted ability to easily tweak my centrally captured settings.


  • Select Pro/E Version
  • Select File
  • Select File
  • Select Mapkey File(s)
  • Press 'CLEAR WORK DIR' to delete all files from working directory
  • Press 'START' to Launch Pro/E based on your selections.

  • Edit the XML File (you need to understand XML!)
  • Press 'SAVE' to Save the overwrite the current XML Database.

    Code Syntax

    The AutoIT community built a customised version of SciTE to more easily edit their scripts. All screen shots are from this product.

    All the externally referenced files are called in with the following lines:

    I actually started out by capturing my lists of acceptable options in plain text files. However I was unhappy with this so changed my approach to capturing all my options and preferences into a single XML file (a database if you will). Rather than write my own code to read XML files, I took advantage of the AutoIT communities great experience and downloaded the _XMLDomWrapper.au3 script. This is included in the code above.


    The XML wrapper script provides additional user defined functions to allow me to more easily process my database of options.

    In these lines I am extracting lists of information so that I can dynamically generate the UI.


    Once the base set of information has been read in from the XML Database, I first initialise the UI.

    In this case I chose to use Tabs to seperate the normal UI from the Admin one. AutoIT has the ability to generate many types of basic controls such as buttons, drop downs, radios, checkboxes, lists, edit controls, images, labels and probably a few more.


    For each group of options that I needed the user to pick from I generated that part of the UI dynamically using code like below.

    The key aspects of this code is that not only does it generate the set of Radio buttons (GUICtrlCreateRadio) that the user sees but it also selects the default based on the preferences set in the database (GUICtrlSetState).


    My interaction paradigm is that the user selects the options they want and then presses a button to launch Pro/E. The code below sets up a couple of buttons that perform this role.

    Buttons when pressed fire events which are then subsequently handled by my functions.


    The typical method of handling UI events is via a while loop as shown below.

    While the GUI methods appear to be rudimentary compared with that of e.g. Visual Basic, the reality is that the simplicity and speed of development is a massively differentiating factor. We can instead focus on getting a functional product delivered to our users. The most important line above is where 'Case $msg = $LAUNCH'. In this situation the utility calls the 'LaunchProE()' function.


    The LaunchProE() function evaluates the user interface to see what is selected. Then it copies the files over into the working directory.

    In the above lines, you can see how we are looping through the controls to see which one is selected using the test 'BitAND(GUICtrlRead($VERSION_RADIOS[$i]), $GUI_CHECKED)= $GUI_CHECKED'.


    The final aim of the function is to open the right Pro/E.

    AutoIT's Run function spawns an Instance of the specified program ($SelVersionExecutable). In this case it launches Pro/E in the working directory ($dest).


    Having the best tools to hand is always a good way of improving your performance. Being able to manage my Pro/E resources is a significant benefit to me personally. Owners of the 'A Pro/ENGINEERS Guide to Pro/Web.Link' book can download the AutoIT resources for this example from Bonus Applications.