Roberto Alves

Scripting and server based computing

Automating project documentations with AutoIT

One picture say more than a thousand words. Because this in some cases I like to include a lot of images on my project documentations. Generally, these pictures are PrintScreens of consoles and their configurations and diagrams that explain some funcionality.

Benefits when you use pictures instead pure text on project documentations:

  • You are sure that all configurations of that screen was documented;
  • It’s easy to read and find what configuration you want (if you organize on chapters);
  • Is more simple to update the documentation, after change configurations;
  • Is more clear that you made the documented configurations;
  • Using scripts you can document everything using a read-only console, without “admin” access to controls or configurations;


But, take screenshots of hundreds of screens and paste on Word documents aligned, formated and described can be a nightmare and take many hours. Or you can use AutoIt and drink a cup while see the autoit script do all documentation for you.

You can do scripts that take screenshots and interact with Word on VBS, but I think that AutoIt is much more simple, with ready functions to Send Keys, activate windows, recognize what window is open, find pixels on screen, etc. It is mean: AutoIT is a powerful tool that gives to you the ability to automate somethings that can be painful with vbs. And there is more 3 advantages: you can compile a .exe of your script, AutoIT is verrry simple and is entire FREE.

www.autoitscript.com

You can start with a simple script that writes something on Notepad (found on AutoIT help):

Run(“notepad.exe”)
;Open the notepad

WinWaitActive(“Untitled – Notepad”)
;Stops the script while wait to Notepad Window appear

Send(“This is some text.”)
;Send the text to Notepad

WinClose(“Untitled – Notepad”)
;Send a close command to Notepad windows

WinWaitActive(“Notepad”, “Do you want to save”)
;Wait for Notepad ask you want save your file

Send(“!n”)
;Send the command ALT+N to say “No” to Notepad question

You can use with send all keyboard standard commands like alt, ctrl, arrows to up, down, left, right, Enter, tab, home, end, etc. And you can have multiple windows and navigate between then. You can find all commands, functions, methods and funcionalitys on Help of the software.

Can you see what you can do with this powerful tool? You can write a script that:

  • Open Winword;
  • Open a specific console like Citrix Managemen Console or Active Directory;
  • Navigates through the console and take screnshots;
  • Alt-Tab to Word, paste pictures and write descriptions for each picture;

On next time that you need do a documentation of that console, you just need run your script and drink a coffee while wait. :D

See below a little code that capture screen from the Farm properties on Citrix Management Console for XenApp 4.5. To run this code, the focus on Citrix Access Management Console must to be on “Presentation Server” and all items below must to be colapsed. Word and Citrix Console must to be previosly opened.

AutoItSetOption(“SendKeyDelay”,1000)

Dim $x
WinActivate(“Citrix Access Management Console – \Remote, 128-bit SSL/TLS.”)
Send(“{RIGHT}”)
Send(“{RIGHT}”)

;Farm Properties

Send(“{!ENTER}”)
For $x=1 to 40
Send(“!{PRINTSCREEN}”)
WinActivate(“Document2 – Microsoft Word”)
Send(“{ENTER}”)
Send(“^v”)
Send(“{ENTER}”)
WinActivate(“Citrix Access Management Console – \Remote, 128-bit SSL/TLS.”)
Next
Send(“{ESC}”)

On future I wll post more complete scripts to do documentations.

Category: Documentation

Your email address will not be published. Required fields are marked *

*