automatic log in large

How-to: Create a shortcut that automatically logs in to any website

automatic loginWould you like to discover how you can make desktop shortcuts

That will automatically open and

Fill in your username and password

Then log you into any website fully automated?

Ever since I learned how to use a script to automate a browser

I have been using scripts to automate and log in to websites.

If you also see the benefit in that

Then in this tutorial:

I will show you step by step how you can easily make shortcuts that automatically login.

At the end of this post, you can get the script as a free download

 

Degree of difficulty:

level 5

In this tutorial we will make a script using the free scripting language AutoHotkey, it will open and log you in using the Internet Explorer browser.

Before we start, all you need are 2 things:

And 14 lines of plain text from this step by step tutorial.

 

Novices are recommended to have a look at this Tutorial

 

Example video: (0:21)

How-to: Create a shortcut that automatically logs in to facebook

 

Now let’s get on with the step by step on how to make a script that will automate your login to any website using Internet Explorer.

Frist I’ll just pick a site that most of us know “Facebook” but remember that you can use this how-to for almost any website.

 

The File to shortcut:

We start by making a new script

autohotkey_650x320

Now if you have AutoHotkey installed you can skip step one in this list.

How to create a new script:

  1. Download and install AutoHotkey.
  2. Right-click an empty spot on your desktop or in a folder of your choice.
  3. In the menu that appears, select New -> AutoHotkey Script.                 (Alternatively, select New -> Text Document.)
  4. Type a name for the file, ensuring that it ends in .ahk. For example: Testing.ahk
  5. Right-click the file and choose Edit Script.

Each script is just a plain text file containing commands that will be executed by AutoHotkey.exe

 

The 14 lines of text:

On the two first lines you will store your login info in two variables. ( Remember that this is a plain text file so if anyone has access to this file your password will be readable )

My_User_Name := "jackiesztuk@Somemail.com"

My_Pass_Word := "funny541"

 

Browser object:

Then we will make a webbrowser object

For this we will use the function ComObjCreate

And then we use the browser object returned from that function

This object is then stored in the variable “web_browser”

web_browser := ComObjCreate("InternetExplorer.Application")

 

A thing to note is that the web browser window starts out invisible by default

So we will set the browsers visible property to true

This way it will be visible so we can see it.

web_browser.Visible := true

 

Now we have a visible web browser object in a variable aka “web_browser”

automatically login jszapp 1

 

Next we will use this object to navigate the IE web browser

For this we will use the browsers navigate method

Lets navigate to Facebook

web_browser.Navigate("www.facebook.com")

 

Now the browser will navigate to the URL “www.facebook.com”

 

Waiting for a web page to load:

But for us to know how long this navigation will take

We will use another property of the browser object

The busy property, this property will be true as long as the browser is busy

So we will test for this with a while loop

while web_browser.busy ; a while loop is a way to keep the script testing an IF like expression

sleep 100 ; IF web_browser.busy is true then sleep 100 milliseconds

This while loop will test the busy property every 100 milliseconds aka 10 times a seconds

 

After the while loop breaks we will put in a little extra sleep (wait time) to make sure any JavaScript is also done before we start

sleep 1000

 

 

So as soon as the web browser stops being busy the while loop will break

And the script will go onto the next lines

 

So now we or the browser is done navigating to “www.facebook.com”

 

Automatically interacting with a website:

Facebook is an html document that’s now loaded in the web browser object

So for us to automate this site we will need to go through the document object

Like this “web_browser.document”

Now it’s time to automatically input our username and password

For this we will need to know what input fields to use

 

This we can do with other script tools or the browser’s build in tools

This time we will use the IE browser’s “DOM Explorer” tool

 

You do this by manually opening an Internet Explorer browser and navigate to Facebook

Now press your right mouse button over the “Email or phone” field and pick

the “Inspect element” item from the drop down menu that appears

 

This will open Explores “DOM explorer” sub window

In this window you will see a line that is selected

looking something like this

<input name=”email” tabindex=”1″ id=”email” type=”text” value=””>

 

From this line we will need the value of the “id” Attribute

So looking at this line will tell us that here the “id” is “email” so let’s use that

 

Now to use this element we will store it in a variable let’s call it “username_input”

To do this we will use the document objects getElementById function

It looks like this

username_input := web_browser.document.getElementById("email")

That line gets the element with the id = “email” and puts it in our variable “username_input”

 

Now we can use this webpage element via our variable “username_input”

automatically login jszapp 2

 

 

Automated filling of web fields:

So to automatically fill in the value of the input field with our username

We will set the “value” property of the element to the data in our “My_User_Name” variable

username_input.value := My_User_Name

So now the “email or phone” input field will hold our username

 

Next we will do the same thing for the password.

Go to www.facebook.com and move your mouse over the password input field

Now right-click it then select the “Inspect element” item from the drop down menu

This will open the DOM tool with a selected line looking something like this:

<input name=”pass” tabindex=”2″ id=”pass” type=”password”>

 

From this line we will again need the value of the “id” Attribute

so looking at this line we can tell that here the “id” is “pass” so we will use that

 

Again we take the element and store it in a variable we call “password_input”

To do this we will again use the document objects getElementById function

So it looks like this for the password

password_input := web_browser.document.getElementById("pass")

That line gets the element with the id = “pass” and puts it in our variable “password_input”

 

Ones again we can use this webpage element via our variable “password_input”

 

Okay to automate the filling in of the value of the password input field with our password

Set the “value” property of the webpage element to the data in your “My_Pass_Word” variable

password_input.value := My_Pass_Word

So now the “password” input field will hold our password

 

Clicking an html Element:

The last thing we need to do is click the Login Button

How to do that? You say!

 

Frist we go to www.facebook.com and move our mouse over the login button

When over the login button you press the right mouse button and

select the “Inspect element” item from the drop down menu

 

This will show the login button element selected in the DOM tool

The line will look something like this:

<input tabindex=”4″ id=”u_0_n” type=”submit” value=”Log In”>

 

 

This time we just need to click the button element

So we will only use the element by its “id”, but not store it in a variable

For this we will use almost the same method as with the other elements

So we will use the document objects getElementById function again

And also the elements “click” method

It will look something like this for the login button.

web_browser.document.getElementById("u_0_n").click()

That line gets the element with the id = “u_0_n” and clicks it with the “click()” method

 

Ending a script:

Now saving and running this script will open an IE browser

And navigate to www.facebook.com and then automatically login

Return

 

automatically login jszapp 3

 

Conclusion:

That is one way to do an automated login to a website like Facebook, now you can use this method to do the same for almost any website you need, this can also be made to open by hotkey and also to automatically login to open websites and more.

 

Keep telling me if  you need more guides to make things like this or anything I missed or does this kind of post even help you out?

If you have any Questions you can always use the comments or contact page

Try it:

To use your new script, continue as follows:

  1. Save and close the file.
  2. Double-click the file to launch it.

To find, exit or edit the script, right-click the green “H” icon in the taskbar notification area.

Notes:

  • Scripts like this can also use exitapp as the ending line to not have to many scripts running simultaneously, as each will have its own icon in the taskbar notification area.
  • Username and password can also be input by the user at startup as seen in the compiled exe below.
  • To have a website launch and login automatically when you start your computer, create a shortcut to the script file in the Start Menu’s Startup folder.

 

Free downloads:

Script (.ahk)

Free – Get

Application (.exe)

Free – Get

 

 

83 Comments

  1. […] How-to: Create a shortcut that automatically logs in to … […]

  2. […] How-to: Create a shortcut that automatically logs in to … […]

  3. […] How-to: Create a shortcut that automatically logs in to … […]

  4. […] 9. How-to: Create a shortcut that automatically logs in to … […]

  5. […] 11. How-to: Create a shortcut that automatically logs in to … […]

  6. […] 4. Create a shortcut that automatically logs in to any website […]

  7. […] 2. Create a shortcut that automatically logs in to any website […]

  8. […] How-to: Create a shortcut that automatically logs in to facebook Watch this video on YouTube Now let’s get on with the step by step on how to make a script that will automate your login to any website using Internet Explorer. https://jszapp.com/how-to-create-a-shortcut-that-automatically-logs-in-to-any-website/ […]

  9. Hello,

    Is possible to run this script with edge chromium or firefox ?

    I tried a lot of combinations in this line ComObjCreate(“InternetExplorer.Application”) , but nothing works 🙁

    thank you so much

    1. Hi ivy,

      in a way yes but not without using a UDF like Chrome.ahk but those are not using the “normal” build-in COM methods, but you can still make the same functionality…

      1. Hi jszadmin, this is fantastic. Would you mind giving the same script lines I’d need to use Chrome? The link you gave is WAY over my head, but your steps are easy and clear for anyone to do. The website I am trying to do this for does not allow using Internet Explorer and I am not permitted to save passwords in my Chrome browser so having this script will save me a ton of time. Just list the lines I’d need and I can get the rest. Thanks

  10. […] How-to: Create a shortcut that automatically logs in to facebook Watch this video on YouTube Now let’s get on with the step by step on how to make a script that will automate your login to any website using Internet Explorer. https://jszapp.com/how-to-create-a-shortcut-that-automatically-logs-in-to-any-website/ […]

  11. […] How-to: Create a shortcut that automatically logs in to facebook Watch this video on YouTube Now let’s get on with the step by step on how to make a script that will automate your login to any website using Internet Explorer. https://jszapp.com/how-to-create-a-shortcut-that-automatically-logs-in-to-any-website/ […]

  12. Lawrence Poole says:

    Hey there, code works great but I’m having 1 problem. When I assign the variables to the inputs, its not triggering a change event. So when I click the login button, its not recognizing as having any text entered. Is there a way to either emulate typing or force triggering the change event?

  13. Great script, really useful!

    I am trying to expand it in order to login to several sites in the same IE session (opening multiple tabs).

    I managed to open a new tab and paste the URL in the address bar, but I cannot insert the user name and password I stored in another variable into the fields:

    This is how I continued the code (sorry, I am relatively new to coding so this might be poorly written):

    Send, ^t

    My_user_name_WL := “XXX”
    My_pass_Word_WL := “YYY”
    WL_URL := “ZZZ”

    Sleep, 100
    SetKeyDelay, 100, 10
    Send, %WL_URL%

    Sleep, 100
    Send, {Enter}

    while web_browser.busy ; a while loop is a way to keep the script testing an IF like expression

    sleep 100 ; IF web_browser.busy is true then sleep 100 milliseconds
    sleep 5000

    username_input_WL := web_browser.document.getElementById(“_58_login”)
    username_input.value_WL := My_User_Name_WL

    password_input_WL := web_browser.document.getElementById(“_58_password”)
    password_input.value_WL := My_Pass_Word_WL

    web_browser.document.getElementById(“sign-in-portal”).click()

    Return

    Please note that I used XXX, YYY, and ZZZ in the variables for privacy reasons, as you can imagine. The script only loads the page, but no text is inserted into the fileds. Any idea how I could improve this? Thanks!

  14. Hello,
    Actually i am unable to give value in username field as the autocomplete property for the same is off. Thus it is not entering the value in the text box as mentioned in the script. Please help me in how to override this property.
    Thanks in Advance!
    Regards,
    Sam

    1. Well autocomplete does not normally have anything to do with how this method works, but without access to the website it’s hard to really say…

      1. Hello Admin,

        The website about which i am talking is https://223.30.120.179/
        Please have a look into it and tell me why i am unable to enter the value in the script.

        1. Any Updates??

  15. Hello jszadmin,

    Actually the website for which i am trying to login has autocomplete=”off” for both username and password. Thus i am unable to enter the value into it using script.
    Is there any way by means of which i can do that.
    Please help !!!

  16. Hi, jsadmin maybe you can help me.
    problem is on the end script. Script login to webservice clicks a button inside, but after that pops up another explorer window to confirm by clicking Ok and nothing happening.
    Please help me with that.

    My_User_Name := “Me”
    My_Pass_Word := “xxxxxxxxxx”
    web_browser := ComObjCreate(“InternetExplorer.Application”)
    web_browser.Silent := true
    web_browser.Visible := true
    web_browser.Navigate(“http://10.10.10.10:8080/”)
    while web_browser.busy ; a while loop is a way to keep the script testing an IF like expression
    sleep 100 ; IF web_browser.busy is true then sleep 100 milliseconds
    sleep 1000
    username_input := web_browser.document.getElementById(“EDLOGIN”)
    username_input.value := My_User_Name
    password_input := web_browser.document.getElementById(“EDHASLO”)
    password_input.value := My_Pass_Word
    web_browser.document.getElementById(“OKBTN”).click()
    while web_browser.busy ; a while loop is a way to keep the script testing an IF like expression
    sleep 100 ; IF web_browser.busy is true then sleep 100 milliseconds
    sleep 1000
    web_browser.document.getElementById(“LBLWEJSCIE”).click()
    sleep 100 ; IF web_browser.busy is true then sleep 100 milliseconds
    sleep 2000
    Send {Enter}
    Return

    1. Hi you can try this function passing in the string title of the new IE window, so you can interact with it.

      web_browser_2 := WBGet("title of new IE window")

      web_browser_2.document.getElementById(“LBLWEJSCIE”).click()
      return

      WBGet(WinTitle="ahk_class IEFrame", Svr#=1) { ;// based on ComObjQuery docs
      static msg := DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT")
      , IID := "{0002DF05-0000-0000-C000-000000000046}" ;// IID_IWebBrowserApp
      ;// , IID := "{332C4427-26CB-11D0-B483-00C04FD90119}" ;// IID_IHTMLWindow2
      SendMessage msg, 0, 0, Internet Explorer_Server%Svr#%, %WinTitle%
      if (ErrorLevel != "FAIL") {
      lResult:=ErrorLevel, VarSetCapacity(GUID,16,0)
      if DllCall("ole32\CLSIDFromString", "wstr","{332C4425-26CB-11D0-B483-00C04FD90119}", "ptr",&GUID) >= 0 {
      DllCall("oleacc\ObjectFromLresult", "ptr",lResult, "ptr",&GUID, "ptr",0, "ptr*",pdoc)
      return ComObj(9,ComObjQuery(pdoc,IID,IID),1), ObjRelease(pdoc)
      }
      }
      }

      hopefully that will help

      1. No, still nothing happening. But if I confirm manually by clicking enter or space it works

  17. some websites wont allow to inspect their elements(i mean right click wont show inspect element option) in that case how can we proceed

  18. does it works with chrome too?

    1. No sorry, the html elements and the methods used are available in Chrome but Autohotkey does not have easy access to them.

  19. I tried this a million different ways and it simply does not work.

    1. Hi sorry to hear that, I’m happy to look at your issue, maybe I can help.

      Drop me a message using my Contact form

      1. sorry, been a frustrating past few days. http://imgur.com/a/KzK8F

  20. Marvelous! Thank you so much. I wish I had seen this years ago when I was first starting with AutoHotkey.

  21. Hiya is there a way I can update information in one website and it updates in other websites as well ro save me cutting and pasting the same info over and over again.

    1. Well yes,

      But there is a good amount that needs to be in place for you to do it!

      1. Sure. Can you tell me how specifically this can be done as far as the good amount that needs to be in place. I want to be able to update quite a few forums that I am a member of with information so that I do not end up repeating myself over and over again.

        Many Thanks,look forward to hearing from you soon

  22. Hello,

    thanks for sharing this…
    It is also possible to login via .htaccess and .htpasswd to access an PC to download a File? The Domain uses https:// to secure the communication. (A little Bit…)

  23. Hi Jack,

    Will you help me to create multiple auto-login to 10-20 websites with using only the Firefox Browser.

    Appreciate your help.

    Thank you
    Chan

    1. Hi CHAN,

      Sorry but this exact method can’t be used with Firefox

      Cheers,
      Jackie

      1. Hi Jack,

        Thank you, Can it be done with Internet Explore but multiple websites to log in with 10-20 username and password please ?

        Many Thanks
        Chan

        1. Hi Chan,

          Yes it can 🙂 most of what you need is already in this tutorial…

  24. […] “log into any website” post (Nice walk-through how to manipulate a web […]

  25. nice jszadmin but i need an another help. can you give me a script for amazon which automatically clicks on buy now button of a specified product in every 10 milliseconds…. please help me……

    1. Hi,
      I’m happy to help you, with something this exact you need to send me a message using my contact form…

  26. Hi Jackie,

    Thanks for this script. Before jumping into it though… Does this work with windows 10? I am a total but enthusiastic beginner so could you please help me with this? Is there still no workaround to use firefox and not explorer (or edge)? Also is private browsing an option?
    I have to login to one website with several accounts and I need either to delete the cookies before login or use incognito/private browsing.

    Thanks a lot,
    Orsi

    1. Hi Orsi,

      Your welcome, it works with windows 10…

      I’m happy to help you with the rest simply send me a message via my contact form 🙂

      HTH
      Jackie

  27. […] How-to: Create a shortcut that automatically logs in to any website […]

  28. […] How-to: Create a shortcut that automatically logs in to any website […]

  29. hi the new google login is hard to get right – can you help?

    1. Hi Dan,

      I’m happy to give you a hand simply hit me with a mail at Admin[at]jszapp.com or use the contact form

  30. Hi Jackie, thanks for the great tutorial! It works perfectly with the websites i’ve tried it with. Problem is: one website I would like to automatically log into doesn’t have an id set for the submit button. Is there a way to use getelementby… name or something?
    Thanks!!

    1. Hi Alicia,

      Thanks glad you like it,

      There are a few methods like “getElementById”

      There is also
      getElementsByTagName
      getElementsByName
      getElementsByClassName

      Anyone of them can most likely be used but can’t really say without knowing more about your page 🙂

      Your welcome to send me the url if it’s a public site use the contact form

      Cheers,
      Jackie

  31. Hi there, I found your blog thru the ahk community, and since i cant make an account there, I thought maybe you could help me out figuring out my problem.

    What I’m trying to do is a script to change my IP easily, basically what it does is access my modem configuration page and change the last mac numbers to something else, making my ISP give me a new IP, but at some point, right after i login its like the object gets disconnected, and I need a function to connect back, why is that happening? Im on Win10 IE11 and here is the code:

    wb := ComObjCreate(“InternetExplorer.Application”)
    wb.Visible := True
    WinMaximize, % “ahk_id ” wb.HWND
    wb.Navigate(“http://192.168.0.1/”)
    IELoad(wb)
    wb.Document.getElementsByTagName(“input”)[0](“loginUsername”).Value := “admin”
    wb.Document.getElementsByTagName(“input”)[1](“loginPassword”).Value := “xxxxxx”
    wb.Document.getElementsByTagName(“input”)[2](“submit”).click() ;from this moment it gets disconnected and I cant use IELoad(wb) or it will be looping forever, so I use sleep
    Sleep, 1000
    wb.Navigate(“http://192.168.0.1/RgSetup.asp”) ;have to use wb.Navigate because it is disconnected and I cant click or get values from the page either.
    wb := WBGet(“Residential Gateway”) ;to connect back to the object
    hexNumber := wb.Document.getElementsByTagName(“input”)[14].Value
    MsgBox % hexNumber

    1. Hi Mark,

      It’s a security feature of IE (seen it before)

      If the object is really disconnected your wb.navigate line will not work or has no use

      Most likely the submit event is what’s disconnecting it so do your sleep and then the WBGet function call

      There is no way to really get around it that i know of.

      Best you can do is what you’re doing now.

      Have you tried the cmd commands “ipconfig /release” – “ipconfig /renew”?

      Cheers,
      Jackie

      1. Hey, thanks for answering and the suggestion.

        I tried those commands yes, but still, my IP doesnt give me a new IP, i heard something about lease time. But thanks!

  32. Hi Jackie,

    I read your tutorial and it works on Internet Explorer which is good. However I want to use Google Chrome for my default web browser to do the automation of log-in in a certain website.

    It is possible to use Google Chrome? if possible can you give me on how can I use it?

    Thanks more power!

    1. Hi Myrts,

      Thanks for asking, ahk don’t have methods built-in in the same way as it does with IE

      I have seen multiple ways of doing with the other big browsers

      Here is an example of using Selenium with ahk https://autohotkey.com/boards/viewtopic.php?f=5&t=11884

      The acc lib can also help with some things https://autohotkey.com/board/topic/90620-firefox-page-load-wait/

      You can also use javascript and inject that or write a plugin/userScript

      Some will work very differently from the script in this tutorial

      But in the end the method show in this tutorial is only for IE sorry

  33. Ok thanks Jackie.

  34. Hello Jackie, just curious, can this also be done using C# or VB.Net, or do you have to use AutoHotKey? Thanks.

    1. Hi Milli,

      You can do it in other languages to

      Depending on the language it can be more or less elegant but still doable.

      Can’t say which will be the easiest one but Autohotkey lets you do it without including anything not build-in

  35. My Facebook is already opened by Internet Explorer, the AHK must fill in the username and password fields.
    Just like you taught:

    username_input: = web_browser.document.getElementById (“email”)
    username_input.value: = Your_User_Name
    password_input: = web_browser.document.getElementById (“pass”)
    input.value password: = my_password

    There is this possibility?

    1. Hi Carlos,

      One way to get a COM object of the currently open IE window
      Is to use the shell windows collection
      To loop over all the open explorer windows

      For WebBrowser in ComObjCreate( "Shell.Application" ).Windows

      And then check the windows title or
      Other things to identify the IE window you need

      There is a nice UDF called IEGet that does this
      It is made by jethrow and can be found almost at the bottom
      Of the first post here

  36. Hello!
    Your code works great to open facebook, great explanation, congratulations!
    I work with the AHK some time, but never used it for Internet Browser, just to systems and etc.
    I tried several forms, fill in the email field and password to the facebook already open and I could not, just the way you did, open the navegardor and then fill in the fields.
    How do I get AHK fill these fields (email and password) with already open browser?
    Thank you very much for your attention and I look forward to your good will.
    Sorry typos, I’m from Brazil and do not command your language, I’m using google translator XD

  37. Thank you so much for your response, Jackie!

    I should mention that I am a beginner at AHK, so please forgive me if I ask some very basic questions.

    I copied and pasted your code and changed the “SecurID Name”, “Passcode”, “Domain\User Name”, and “Password” values to my own. I also had to comment out the sign in button because I have to append a six-digit code from a random number generator provided by the company to the end of my Passcode.

    I am still receiving the following error message:

    “Error: 0x80010108 – The object invoked has disconnected from its clients.
    Specifically: readyState
    Line#
    005: while wb.readyState!=4 || wb.document.readyState != “complete” || wb.busy
    Continue running the script?”

    I am not sure if I was supposed to change anything else…
    Please let me know.

    Thank you again,
    Katherine

    1. Hi no problem happy to help,

      We’ve all been beginners so don’t sweat it,

      The code works for me up to the part where it submits the form, as I don’t have a reel login 🙂 I can’t test more then that.

      If your error is coming up after that it’s hard for me to debug…

      Maybe there’s some special coding in the live page that causes this or it loads a new windows/tab or uses frames

      Hard for me to help if that’s the case.

      If you feel there is any more information you can give me, video or something

      That will help me help you, you’re welcome to post it or send it to me…

      Cheers,
      Jackie

      ps.: Have not found any issue with the contact form and it works for others so not sure what the issue is at this point in time, i’ll keep testing.

      1. Hi Jackie,

        I was just expecting the script to fill in most of the form for me, so that I can simply add in the randomly generated number and click submit. Kind of like the autofill feature when using Google Chrome.

        When I run the code, it opens up a new Internet Explorer window and navigates to the web page, but all the fields remain blank, and then I get various error messages asking if I want to “Continue running the script?” Every time I select yes, another error message pops up.

        I cannot figure it out. I wonder if it is a problem with my laptop or something.

        Thanks again,
        Katherine

  38. Hi Jackie,

    First of all, I really enjoy reading your posts. Thank you for creating this site.

    I am experiencing a lot of difficulty with your Contact form. The error message I keep receiving is “Invalid characters in POST. Possible email injection attempt”.
    Why am I getting this message over and over again?!? So, now I will try to submit my question through your comments.

    I have been trying to use your tutorial to automatically fill in a login form with my information (https://inet.bmofg.com/dana-na/auth/url_default/welcome.cgi)
    However, I kept getting the following message:

    “Error: 0x80010108 – The object invoked has disconnected from its clients.
    Specifically: document
    Line#
    011: securid_input := web_browser.document.getElementById(“username”)
    Continue running the script?”

    I tried using getElementsByName and that did not work either. Then, I found your response (http://autohotkey.com/board/topic/111639-filling-web-forms-using-com/) so I tried adapting that for my purposes, but I am still receiving similar error messages. I am using AutoHotKey 1.1.22.3.

    Any help or suggestions would be greatly appreciated.

    Thanks,
    k

    1. Hi K

      Thank you for reading and commenting, Sorry to hear about your issues i’ll look into the contact form error…

      Can’t say why you’re getting a disconnect error, i tested it and i don’t seem get any kind of errors,

      getElementsByName worked for me in my short test… but I still made a small example of an alternative way to do it

      url := "https://inet.bmofg.com/dana-na/auth/url_default/welcome.cgi"
      
      wb := ComObjCreate("InternetExplorer.Application")
      wb.Visible := true
      wb.Navigate(url)
      while wb.readyState!=4 || wb.document.readyState != "complete" || wb.busy
             sleep 10
             
      table := wb.document.getElementById("table_LoginPage_6")
      
      inputs := table.getElementsByTagName("input")
      
      loop % inputs.length
      {
          name := inputs[A_index-1].name
          if (name = "username")
              inputs[A_index-1].value := "SecurID Name"
          else if (name = "password")
              inputs[A_index-1].value := "Passcode"
          else if (name = "user#2")
              inputs[A_index-1].value := "Domain\User Name"
          else if (name = "password#2")
              inputs[A_index-1].value := "Password"
      }
      
      wb.document.getElementById("btnSubmit_6").click() ; sign in button
      while wb.readyState!=4 || wb.document.readyState != "complete" || wb.busy
             sleep 10
      return

      Let me know if that helps you…

      Cheers,
      Jackie

  39. Thank you very much for doing this and publishing it. I have been trying to do this for an year, and showed my the process rather than just giving an file.

    1. Your welcome, nice to know it helped you.

  40. Having your login credentials stored in plain text is a pretty bad opsec violation. I’d discourage doing that for any service that stores or has access to any sensitive information.

    1. While it’s true that if your computer is hacked, plain text passwords make the attacker’s life really easy — at that point, does it even matter? He’ll still be able to log everything you do or type anyway.

      1. Hey! really nice tutorial. I want to ask some questions. After login, is there any way to find out on which page we are redirecting? and also how to select a value from dropdown?

        1. Hi Muhammad,

          Thank you, glad you like it.

          Regarding your question about redirecting, I don’t know what your asking about, can you please go in to more details!

          If its a normal html Element like a < select >, then most of the time you can use the selectedIndex or Value to select one of the options by option index number or by option value.

          Example:

          Then to select option 2 “Only search in titles” you’d use one of the two from above like this

          wb.document.getElementById("search_content").selectedIndex := 1 ; zero based
          wb.document.getElementById("search_content").value := "titles"
          1. Thanks for your answer. Actually my first question was, after enter credentials and clicking on the submit/login button, how do we know on what html/website page we are being redirecting? Hope you understand it now.

          2. Hi Muhammad,

            That’s hard to say, as it depends on the page your trying to log in to.

            Some pages have the info in the login form’s outerHtml, like facebook:

            if you look at the forms action attribute you can see what url is used to login

            That’s not the same as the url your being redirected to tho, as that’s probably done by a server side script…

            Was that along the lines of what your asking about?

          3. Yep that is it. Thanks for your response.

            Thanks a lot.

  41. I was able to figure out how to get the selected option in a scrolldown box using Com in AHK. I don’t know if you’re interested or if you already–I’m sure you are an expert so this may not help you. Anyways, my line looks like this:

    wb.document.all.reason.value := Value

    I used debugger in IE. I wasn’t able to inspect element on that particular scrolldown box.

    1. Great David

      Good to hear you got it working, when setting the selection of a “Select” element you may also use “.selectedIndex := 1” insted of the value

      >> I used debugger in IE. I wasn’t able to inspect element on that particular scrolldown box.

      Yeah some Elements can be hard to inspect, when that happens you may need to look at the html or code of the page to find the infomation you need.

  42. How do you use Dom to inspect the element of a box that you have to click on and make a scroll down selection. Also how do you do the same If you were to input data into a field and it generates a corresponding pop up that you have to click on. BTW I love your video and tutorial and it worked great but for some websites I’m trying to use this on it won’t work. I’m just learning from examples I see on the net

    1. Hey David
      One of the problem’s with automating website’s is that there are lots of ways to do the same thing. So without knowing the way it’s done on the site you a trying to login to, it will be hard for me to give you a working answer. Sorry

      >>BTW I love your video and tutorial and it worked great

      Glad you liked it 🙂

  43. […] Novices are recommended to have a look at this Tutorial […]

Leave a Reply