Jump to content
Sign in to follow this  
NewPlaza

IE autologin username/password

Recommended Posts

NewPlaza

Hello,

I am tring to automate my login for a specific site and having much trouble interacting with the page.  I have interacted with other webpages in the past but this one seems very nested and I can't seem to get it.

I just want it to add my username/password on the available fields.  Nothing more.

Here's the page.

Thanks.

AcmeService.htm

Share this post


Link to post
Share on other sites
Kidney

you will need to get a hold of the handle of the form on the page. once you do that, you should then be able to access the input boxes for username and password

Share this post


Link to post
Share on other sites
NewPlaza

you will need to get a hold of the handle of the form on the page. once you do that, you should then be able to access the input boxes for username and password

 

The handle? What do you mean by that.  Sorry for my ignorance.  I know almost nothing about HTML and DOM.

In fact the many times I have interacted with webpages much came examples and such. Still learning.

Share this post


Link to post
Share on other sites
Xenobiologist

#include<IE.au3>
$sUsername = "Username"
$sPassword = "Password"
$sUrl = "http://www.yourURL.com"
$oIE = _IECreate($sUrl, 0, 1, 0, 1)
Sleep(2000)
$oHWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($oHWND, "", @SW_MAXIMIZE)
$oForm = _IEFormGetCollection($oIE, 0)
$oUsername = _IEFormElementGetObjByName($oForm, 'ID_LOGON_UserNameText')
$oPassword = _IEFormElementGetObjByName($oForm, "ID_LOGON_PasswordText")
_IEFormElementSetValue($oUsername, $sUsername)
_IEFormElementSetValue($oPassword, $sPassword)
_IEFormSubmit($oForm)

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
NewPlaza

@Xenobiologist

Thanks but I can't seem to make it work.  Anyhow I had to redo my code for the other sites because it would not add the login information if a second browser window was opened.

This is what I came up with for the few others I have automated.

If WinActive("Acme Site1") Then
        If StringInStr(WinGetText("[active]"), "Acme Site1 - Windows Internet Explorer") Then
            Local $hActiveWindow = WinGetHandle("[active]")
            Local $WindowList = WinList("Acme Site1")
            For $i = 1 To $WindowList[0][0]
                Local $oIE = _IEAttach("Acme Site1", "TITLE", $i)
                Local $hCurrentWindow = _IEPropertyGet($oIE, "HWND")
                If $hCurrentWindow = $hActiveWindow Then
                    $oUserID = _IEGetObjByName($oIE, "login_id")
                    $oUserID = _IEFormElementGetValue($oUserID)
                    If Not $oUserID = "MyLoginName" Then
                        $oUserID = _IEGetObjByName($oIE, "login_id")
                        $oPassword = _IEGetObjByName($oIE, "login_id_password")
                        _IEFormElementSetValue($oUserID, "MyLoginName")
                        _IEFormElementSetValue($oPassword, "XxXxXxX")
                    EndIf
                EndIf
            Next
        EndIf
    EndIf

I just cant make this last site work..Any suggestions would be great.

Share this post


Link to post
Share on other sites
Xenobiologist

And what happens? Any errors?


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
NewPlaza

I get dozens of warning from scite.

--> IE.au3 V2.4-0 Warning from function _IEFormElementGetObjByName, $_IEStatus_NoMatch
--> IE.au3 V2.4-0 Warning from function _IEFormElementGetObjByName, $_IEStatus_NoMatch
--> IE.au3 V2.4-0 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType
 

Share this post


Link to post
Share on other sites
corgano

The help file is brilliant! Go to SciTE, click a function name, and hit F1. It will show you the function in the help file, as well as an example. Another great tool is google chrome's inspect element (or on IE hit F12 and a similar tool pops up). You can have it highlight the element you want to fill in, and you can see in the HTML what it is called. Using this you can get the names of almost every element that exists, the forum, anything!

If you plan to do any pattern matching / regexpwork, _IEBodyReadHTML() will show you exactly what IE sees, and http://gskinner.com/RegExr/ is AWESOME for making and testing RegEx statements. That and stringregexp() will make IE automation easy

and CONSULT THE HELP FILE! It's amazingly helpful :P


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites
alexstone

Is it necessary to use script to make auto login? Maybe there is another way?

Share this post


Link to post
Share on other sites
corgano

log in manually!


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites
NewPlaza

log in manually!

812 posts and counting!!

Share this post


Link to post
Share on other sites
NewPlaza

Okay  This seems to work with the attached HTM file.  I'll know more next week if it will work on the 'live' site.

If WinActive("acme") Then
        If StringInStr(WinGetText("[active]"), "acme - Windows Internet Explorer") Then
            Local $hActiveWindow = WinGetHandle("[active]")
            Local $WindowList = WinList("acme")
            For $i = 1 To $WindowList[0][0]
                Local $oIE = _IEAttach("acme", "TITLE", $i)
                Local $hCurrentWindow = _IEPropertyGet($oIE, "HWND")
                If $hCurrentWindow = $hActiveWindow Then
                    Local $oForm = _IEFormGetCollection($oIE, 0)
                    Local $oUserID = _IEFormElementGetObjByName($oForm, "ID_LOGON_UserNameText")
                    $oUserID = _IEFormElementGetValue($oUserID)
                    If Not $oUserID = "TestName" Then
                        Local $oUserID = _IEFormElementGetObjByName($oForm, "ID_LOGON_UserNameText")
                        Local $oPassword = _IEFormElementGetObjByName($oForm, "ID_LOGON_PasswordText")
                        _IEFormElementSetValue($oUserID, "TestName")
                        _IEFormElementSetValue($oPassword, "TestPassword")
                    EndIf
                EndIf
            Next
        EndIf
    EndIf

There are a few warnings with the above code but at lease its doing more then what it did before.

Share this post


Link to post
Share on other sites
bogQ
dumb question, but because of this code inside that htm file ---if(window.parent.document.getElementById("IFrame1"))---, isn't maybe that you're login is inside iframe when you try to get its elements?
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites
Xenobiologist

Another way would be using a e.g. firefox plugin callled iMacros. That way it is so damn easy to automate a login. :-)


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
NewPlaza

 

dumb question, but because of this code inside that htm file ---if(window.parent.document.getElementById("IFrame1"))---, isn't maybe that you're login is inside iframe when you try to get its elements?

 

I have absolutly no idea.

Another way would be using a e.g. firefox plugin callled iMacros. That way it is so damn easy to automate a login. :-)

IE only.. ff not allowed..

Share this post


Link to post
Share on other sites
Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
corgano

Query, what is the live site? If it is public, we could actually SEE what we're doing and make an account to try it out ourselves. It'd be much easier to help you


0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Share this post


Link to post
Share on other sites
NewPlaza

Query, what is the live site? If it is public, we could actually SEE what we're doing and make an account to try it out ourselves. It'd be much easier to help you

It's a work intranet addy.  Anyhow, I was not successful in automation this particular site.. bummer. Oh well..  8 out of 9 is automated is good.

@Xenobiologist

Thanks for the link but that is to big to install on my workstation with no "real" justifiable reason.

 

Thanks for eveybodys help here.  I will just have to play with it some more.  I'm sure I'll get it in time.

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  

×