Using AutoIt Recorder.

Have you ever heard about macro’s? If not, they were used commonly from early 90’s by many programs. Text editors (like wordperfect or professional write), spreadsheets (like lotus) and many other tools were providing macros. But what’s a macro?

A macro is a “command”, that when executed, expands to a set of commands. Let say then we want to do 3 different things which need 3 actions to happen, but we want to do that with 1 action instead of 3. A solution may be to use a macro.

Not every software “supports” macro’s. But many widely used programs do support. I will mention Word & Excel as I believe that most of you have used them.

But what happens if we do need to use a “macro” in a software not providing such functionality? AutoIt can give you such a functionality. What it can do is to “record” what you want to do, and after that it generates a script which will work like a macro. It will emulate keystrokes and mouse movements, and send any command recorded in the macro to the application in which the macro should be executed. But how do we create a macro in autoit?

AutoIt comes with a lot of tools. One of them is the AutoIt Recorder. Using this tool we can record a sequence of actions, keystrokes and even mouse moves and clicks (single or double), not only for one application though usually this is the case. AutoIt Recorder can be easily launched by creating a new script. Simply we create a new Text Document, and change the extension from .txt to .au3. After we select the script file we created and right click on it. From the available options we select the “Edit Script”. Normally the editor used by AutoIt, which normally is Scite, should launch. From Scite’s menu we choose “Tools->AU3Recorder” (actually there is also a shortcut we can use “Alt-F6”). As shown in the following screenshot, the AutoItRecorderrecorder is simple. It contains three checkboxes and a field to set the application to run and to record the actions. The big icon button on the left is normally blue and says bellow “Click To Record”. While the Recorder is working it blinks from blue to red. A click on that button starts or ends the recorder depending on the active state when pressed.

If during the recording it captured some actions (keystrokes, mouse moves or clicks), when stoped, those actions will show to the autoit editor like in the following example.

#region --- Au3Recorder generated code Start (v3.3.9.5 KeyboardLayout=00000409)  ---

Run('notepad')
_WinWaitActivate("Untitled - Notepad","")
Send("test{TAB}{ALTDOWN}{F4}{ALTUP}")
_WinWaitActivate("Notepad","")
Send("{RIGHT}{ENTER}")
#endregion --- Au3Recorder generated code End ---

Actually the code above should run in any computer runing windows (with autoit installed on it). The example above will open a notepad window, write to the editor the word “test” with a tab character at the end, and then will close notepad without saving any changes.

The AutoIt Recorder really makes the creation of “macros” to the OS side a simple task, giving the possibility even to simple users to easily automate some simple tasks.

Hope you’ll find that post useful.

Andreas.

Advertisements