Keung Posted July 5, 2010 Posted July 5, 2010 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.
jfcby Posted July 6, 2010 Posted July 6, 2010 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 ****
Keung Posted July 7, 2010 Author Posted July 7, 2010 Hi jfcby, I tried your suggestion, but the web has 2 buttons with Javascript function. The button cannot be clicked by _IEFormSubmit($o_form) Keung
jfcby Posted July 7, 2010 Posted July 7, 2010 Try this... expandcollapse popup#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 ****
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now