Jump to content

Login script


Recommended Posts

Hi,

I got some problems when writing a script to do auto login program.

I capture the main html code for login as below.

###############################################################################

<script language="Javascript">

var sbHand;

function Login(sSide)

{

if(sSide == "A")

{

sbHand.loginNormal();

}

else if(sSide == "B")

{

sbHand.loginVIP();

)

else

{

return;

}

}

</script>

<form name="login_form" action="login.asp" method="get">

<input name="username" class="xxxx" type="text" size="20" maxLength="100" />

<input name="passwd" class="xxxx" type="password" size="20" maxLength="100" />

<input class="xxxx" onclick="Login('A') type="button" value="Normal Login" />

<input class="xxxx" onclick="Login('B') type="button" value="VIP Login" />

###############################################################################

Then I wrote the following script for fill in the username and password. It works.

However, I don't know how to write the action for _IEAction since there is no name for the button and the Javascript function is called.

; My script

$o_username = _IEFormElementGetObjByName ($o_form, "username")

$o_password = _IEFormElementGetObjByName ($o_form, "passwd")

$username = "myusername"

$password = "mypassword"

_IEFormElementSetValue ($o_username, $username)

_IEFormElementSetValue ($o_password, $password)

Do you have any idea to solve it?

Thanks.

Link to comment
Share on other sites

Keung,

Add this to the end of your script:

_IEFormSubmit ($o_form)

jfcby

Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Link to comment
Share on other sites

Try this...

#include <IE.au3>

Global $oIE, $o_form, $colButtons, $oValue1, $oValue2 

$WebpageTitle = "Webpage Title" ;<<< Change
$username = "myusername" ;<<< Change
$password = "mypassword" ;<<< Change

;Set IE Form Elements
$oIE = _IEAttach ($WebpageTitle)                
$o_form = _IEFormGetObjByName ($oIE, "login_form")      ;<<< Change Form Name

; My script
$o_username = _IEFormElementGetObjByName ($o_form, "username") ;<<< Change Username Form Field Name
$o_password = _IEFormElementGetObjByName ($o_form, "passwd") ;<<< Change Password Form Field Name


_IEFormElementSetValue ($o_username, $username)
_IEFormElementSetValue ($o_password, $password)

_SetIEButtons()

_IEAction ($oValue1, "click") ;<<< Change to $oValue1 = " Narmal Login" or $oValue2 = "VIP Login"


Func _SetIEButtons()
    ;
    $colButtons = _IETagNameGetCollection($oIE, "button")
    
    ;   
    $btnValue1 = "Normal Login" ;<<< Change button 1 value
    $btnValue2 = "VIP Login" ;<<< Change button 2 value 
    
    For $oButton In $colButtons     
        If $oButton.value = $btnValue1 Then $oValue1 = $oButton
        If $oButton.value = $btnValue2 Then $oValue2 = $oButton
        
        ConsoleWrite("Debug Button: tagname = " & $oButton.tagname & @TAB & "id = " & $oButton.id & @TAB & _
        " title = " & $oButton.title & @TAB & " classname = " & $oButton.className & @TAB & " value = " & $oButton.value & @LF) 
    Next
    
EndFunc     ;==>_SetIEButtons

jfcby

Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...