Wednesday, February 16, 2011

Use Autoit v3 to make auto Login script(Internet explorer automation)

Do you login to various web accounts and type Username and passwords hundreds of time daily? Yes ! then you are wasting your valuable time which could have been used in some other productive work. Instead you can create an .EXE file to directly login into your website.Below are the ingredients needed to do so.
  • Autoit v3
  • IE UDF .Thats all.
  • Google chorme to easily identify DOM element ID or NAME parameter ,else you can view source in any browser of your choice rather I recommend use of Google chrome
Now open the website you want to login into(here i have used yahoo.com as an example) and right click on the Text field for username and or password and click Inspect element from the context menu
now you can copy ID or Name of element(textfield) from the page to be used in programming,dont forget to cope the form element name or id along with it.

#include 
$oIE = _IECreate ("http://yoursitename.com")
$oForm = _IEFormGetObjByName ($oIE, "form id or name")
$oQuery1 = _IEFormElementGetObjByName ($oForm, "uname textfield id or name")
$oQuery2 = _IEFormElementGetObjByName ($oForm, "pwd text field id or name")
$uname="Yourusername"
$pwd="yourpassword"
_IEFormElementSetValue ($oQuery1,$uname)
_IEFormElementSetValue ($oQuery2,$pwd)
$oButton=_IEGetObjById($oIE,"")
_IEAction ($oButton, "click")
_IELoadWait($oIE,0)

The code above opens internet explorer finds the text-fields for username and password further it sets the string using _IEFormElementSetValue() fuction and finally simulates the click on the form button to submit the form 
Download Script here
Further you can compile the script and make an exe file just to click and login into specific website

Auto IT Language for Scripting

Auto IT is a powerful scripting language for Windows COM and GUI automation.It can be used to automate mouse clicks and keyboard strokes.
This is an Opensource effort and is running under GNU-GPL licensing system,Major advantage of using Auto IT is the availability of various UDF-user defined functions which can be easily imported and used to automate day to day applications like Internet explorer and Office applications.Live and hot forums also adds reason for opting such a nice thing.
With easy to implement syntax this is a boon for a non programmers or a new programmers who want to achieve a lot with less effort and easily turn their idea to reality. After all we all are very lazy to do a monotonous work in our systems so why not automate those tasks and save our time and effort !