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

5 comments:

Greg San Diego said...

hi. im new to autoit. ive just created my first autoit script. its a loop that just waits for special 'hot key' combinations to be entered by me. im forced (by company policy) to run the google chrome browser. we use a web-based customer management system, known as salesforce.com ive figured out how to automatically 'move about' such a web page in edit mode (technically it is a form). and jump to different fields using {TAB} or control{TAB}, to change fields in the form. the only thing i dont yet understand how to do with autoit is how to find and move to either hyperlinks or form-submit-buttons, and then cause the button to be clicked. do you have any suggestions where i can go to learn more about this

Unknown said...

Thank you :)
I want code working on the google.
I tried edit it, but he Did not work with me !
this is my code :
#include
$oIE = _IECreate ("https://accounts.google.com/ServiceLoginAuth")
$oForm = _IEFormGetObjByName ($oIE, "gaia_loginform")
$oQuery1 = _IEFormElementGetObjByName ($oForm, "Email")
$oQuery2 = _IEFormElementGetObjByName ($oForm, "Passwd")
$uname="w2y2w"
$pwd="222222"
_IEFormElementSetValue ($oQuery1,$uname)
_IEFormElementSetValue ($oQuery2,$pwd)
$oButton=_IEGetObjById($oIE,"")
_IEAction ($oButton, "submit")
_IELoadWait($oIE,0)




Peakbagger said...
This comment has been removed by the author.
Peakbagger said...

Can you put a larger screenshot of the code Yahoo page code? I cannot see what you've got highlighted. Tried downloading the JPG and viewing but extremely small.

H said...

Hi! thanks for this, could you please post the same code but for Chrome?

Post a Comment