How to use the Automation Language AutoIt in Combination with UiPath


#1

It seems to be a litte bit as an antagonism to use another desktop automation solution in the context of UiPath. But my perspective is that each integration scenario is allowed as long you reach your final target fast and secure. In this post I describe how to use AutoIt in the context of UiPath, to complement particular activities which you can’t use easily otherwise. In this consideration I refer to my question about the possibility of recording the X and Y position of the mouse pointer with the UiPath recorder. Here I just wanted to record my mouse movements on the canvas of Microsoft Paint.

AutoIt is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It contains AutoItX, a DLL version of AutoIt that provides a subset of the features of AutoIt via a COM interface. We can very easily install a package of AutoItX from the NuGet Gallery via Manage Packages.

To test it we implement a very easy test via an Invoke Code activity. We move the mouse pointer from its actual position to 0, 0 with the slowest speed.

002

If we run that test we experience a surprise, an exception. :face_with_raised_eyebrow:

003

The error message told us that it can’t find the dynamic link library AutoItX3.dll. To correct this error we copy this library from build directory to lib directory. We must do this in the .nuget\packages directory of the %HOMEPATH%, in my case Users\root. If we run this test again now, it will work fine. The mouse pointer moves slowly from its actual point to the position 0, 0 on the screen. Good :slightly_smiling_face:

In the next step we use the AutoIt recorder. But at first we must download release 3.3.14.0 from AutoIt archive and unpack from zip archive the files Au3Record.exe and ASWhook.dll from directory Extras/Au3Record. Unfortunately is the recorder not available in the actual releases of AutoIt anymore. Now we start the recorder an record any activities on the canvas of Microsoft Paint.

We get a list of mouse moves which we copies from the recorder to a Invoke Code activity from UiPath. All we have to do now is to set the prefix AutoIt.AutoItX- in front of every command. You can do this very fast via an replace command in your favorite editor. Replace CrLf with CrLfAutoIt.AutotItX. Now only the first line we must change manually.

006

This Invoke Code activity is part of the following workflow. It contains the Start Process activity to open Microsoft Paint and a sequence to choose the pencil and the color. Then the strokes are painted on the canvas via AutoItX. After that we choose in another sequence text and color and then we write via AutoItX a text on the canvas.

And here the result, also as video. Great, all works as expected :smiley:

The combination of UiPath and AutoItX offers us the possibility to record mouse activities on elements which we can’t reach with UiPath at the moment. In my opinion it is not bad to use different automation solutions together if they help us quickly to come to a solution. The basic concept of UiPath allows us this possibility, we should not be afraid to use it.