Pages

Sunday, September 13, 2009

How to automate tasks with AutoIt AU3Recorder

   AutoIt allows recording of a series of action and then playing them back (recording a macro). Besides AutoIt, you need also the script editor (SciTE4AutoIt3). After you install both, run Scite, create a new file with .au3 extension, and run AU3 Recorder, either from the tools menu or with Alt+F6 combination (This option is not present if the file being edited is not au3).




This is a good start to begin automating simple things on windows. After crating the au3 script, it can be edited manually if it needs adjustments and then run every time.  


Any possible scenarios can be imagined and automated, starting from clicks and key combinations, installing programs, running tasks....
Great productivity increase:) 
Simple example of automation some browser stuff (selecting text, copying, open tabs,..):
Func Solve()
 Dim $i, $result, $input
 
 For $i = 5 To 1 Step -1
  ; Double left click at cursor position (mouse button swapped from Control Panel)
  MouseClick("right", Default, Default, 2)

  Send("^{c}")   ; Copy
  $input = ClipGet()  ; Get clipboard content
  $result = StringCompare($input, "fail", 1)
  If $result <> 0 Then
   Print($adr, 2000)
  EndIf

  Send("^{t}")   ; Open new tab in browser 
  Send($adr,0)    ; Type address
  Send("{ENTER}") ; Hit Enter
  
  Sleep(1000)
 Next
EndFunc    ; ==> Solve()

Func Print($string, $time)
 ToolTip($string)
 Sleep($time)
 ToolTip("")
EndFunc   ;==>Print()
References:

5 comments: