Sign in to follow this  
Followers 0
JanTrance

Auto login script with multiple tabs opening.

2 posts in this topic

Hi dear users of autoit,

Please help me making this script work. When i use the: "_IECreate" to make a website my script works fine and i can set the focus on an input box and send a keyboard combination which will automatically log me into that website. But on my second and any other tab it doesn't work. Cause i can't seem to get the _IEGetObjByName to look at the currently opened tab, it looks only at the IECreate and not at the new opened tab and the tab after that and so on untill i have 16 webpages open (i need that many for my work). So i am building a script which opens all those webpages and logs in on them all. I am very close it's just this last part where I need the script to search on the current tab and not at the create website. Anyways here is my script:

The script doesn't include all the websites its just a part of it to show you guys where i am stuck.

#include <IE.au3>
#Include <WinAPI.au3>

Const $navOpenInNewTab = 0x0800
Global $o_IE = _IECreate("http://www.firstwebpage.com")
Call ("login")
sleep(1000)

$o_IE.Navigate2("http://www.secondwebpage.com", $navOpenInNewTab)
Call ("login")
sleep(1000)

func login()
$username = _IEGetObjByName ($o_IE,"username")
_IEAction($username, "focus")
call ("keepass")
EndFunc

func keepass()
   sleep(1000)
   Send("^!a")
   sleep(1000)
Endfunc

That username object is per site different so i will need to make more variables for every different username typein field.

But the problem is just that on the IEcreate the script will get the data from the website and set the focus on the username field on the first site and call keepass and type in my password and log in onto that website, but on the second website it doesn't want to get the objectbyname from that new tab.

And i know that: "$username = _IEGetObjByName ($o_IE,"username")", $o_IE <<<<< should be something different, but the problem is that i don't know what i have to put here, so that it searches on the current open tab for an input type="text" and puts the focus on that.

I have tried googling and searching on the forums and on the autoit website, and i can find information but nothing is complete and doesn't use multiple tabs in its script just one login page.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi JanTrance,

easiest way is to use _IEAttach this will allow you to specify which tab you want to use

so after creating the new tab you will want to name it give it an instance of something other than $o_IE this way you can discern which tab you would like which login to go on no matter which order they appear in.

For Example:

#include <IE.au3>
#Include <WinAPI.au3>

Local $tab = Null
Const $navOpenInNewTab = 0x0800
Global $o_IE = _IECreate("http://www.firstwebpage.com")
$tab = $o_IE
Call ("login")
sleep(1000)

$o_IE.Navigate2("http://www.secondwebpage.com", $navOpenInNewTab)
sleep(1000)
$o_IE2 = _IEAttach("IE Title");The Title meaning the websites Description on the Tab
$tab = $o_IE2
Call ("login")

func login()
    $username = _IEGetObjByName ($tab,"username")
    _IEAction($username, "focus")
    call ("keepass")
EndFunc

func keepass()
   sleep(1000)
   Send("^!a")
   sleep(1000)
Endfunc

I haven't tested it but it should be what you need. Can I also suggest that if you wish to use multiple usernames and passwords for different websites that you put them in an array, it will be easier for you to control using the same login function.

Edited by Rampantshadow

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0