Klexen Posted October 31, 2007 Posted October 31, 2007 #include <IE.au3> $sURL = "https://service.cox.com/profile/Login.do?TARGET=-SM-https://service.cox.com/billpay/AccountSummary.do" $sUsername = "asd@asd.com" $sPassword = "mypass" $oIE = _IECreate($sURL) $HWND = _IEPropertyGet($oIE, "hwnd") WinSetState($HWND, "", @SW_MAXIMIZE) _IEAction($oIE, "visible") _IELoadWait($oIE) $oIE = _IEAttach("Cox Communications Login") $oForm = _IEFormGetCollection($oIE, 1) $oUsername = _IEFormElementGetObjByName($oForm, "username") $oPassword = _IEFormElementGetObjByName($oForm, "password") _IEFormElementSetValue($oUsername, $sUsername) _IEFormElementSetValue($oPassword, $sPassword)
Nahuel Posted October 31, 2007 Posted October 31, 2007 (edited) #include <IE.au3> $sURL = "https://service.cox.com/profile/Login.do?TARGET=-SM-https://service.cox.com/billpay/AccountSummary.do" $sUsername = "asd@asd.com" $sPassword = "mypass" $oIE = _IECreate($sURL) $HWND = _IEPropertyGet($oIE, "hwnd") WinSetState($HWND, "", @SW_MAXIMIZE) ;~ _IEAction($oIE, "visible") ;~ _IELoadWait($oIE) ;~ $oIE = _IEAttach("Cox Communications Login") ;~ $oForm = _IEFormGetCollection($oIE, 1) $oUsername = _IEGetObjByName($oIE, "username") $oPassword = _IEGetObjByName($oIE, "password") _IEFormElementSetValue($oUsername, $sUsername) _IEFormElementSetValue($oPassword, $sPassword) _IEImgClick($oIE,"https://service.cox.com/images/btn_Login.gif");I guess it could be done with _IEFormSubmit() as well but you'd need to use _IEFormGetCollection($oIE, 0) Edited October 31, 2007 by Nahuel
Brickoneer Posted October 31, 2007 Posted October 31, 2007 (edited) This would also work. Your problem was the _IEformGetCollection. It returns a 0-based index. (there was no form #1) #include <IE.au3> $sURL = "https://service.cox.com/profile/Login.do?TARGET=-SM-https://service.cox.com/billpay/AccountSummary.do" $sUsername = "asd@asd.com" $sPassword = "mypass" $oIE = _IECreate($sURL) WinSetState($oIE, "", @SW_MAXIMIZE) $oForm = _IEFormGetCollection($oIE, 0) $oUsername = _IEFormElementGetObjByName($oForm, "username") $oPassword = _IEFormElementGetObjByName($oForm, "password") _IEFormElementSetValue($oUsername, $sUsername) _IEFormElementSetValue($oPassword, $sPassword) Edited October 31, 2007 by Brickoneer
Klexen Posted October 31, 2007 Author Posted October 31, 2007 (edited) #include <IE.au3> $sURL = "https://service.cox.com/profile/Login.do?TARGET=-SM-https://service.cox.com/billpay/AccountSummary.do" $sUsername = "asd@asd.com" $sPassword = "mypass" $oIE = _IECreate($sURL) $HWND = _IEPropertyGet($oIE, "hwnd") WinSetState($HWND, "", @SW_MAXIMIZE) ;~ _IEAction($oIE, "visible") ;~ _IELoadWait($oIE) ;~ $oIE = _IEAttach("Cox Communications Login") ;~ $oForm = _IEFormGetCollection($oIE, 1) $oUsername = _IEGetObjByName($oIE, "username") $oPassword = _IEGetObjByName($oIE, "password") _IEFormElementSetValue($oUsername, $sUsername) _IEFormElementSetValue($oPassword, $sPassword) _IEImgClick($oIE,"https://service.cox.com/images/btn_Login.gif");I guess it could be done with _IEFormSubmit() as well but you'd need to use _IEFormGetCollection($oIE, 0) You rock dude, thanks! How would you click that login button? Edited October 31, 2007 by Klexen
Nahuel Posted October 31, 2007 Posted October 31, 2007 (edited) No problem, but brickoneer's solution is better, IMO: #include <IE.au3> $sURL = "https://service.cox.com/profile/Login.do?TARGET=-SM-https://service.cox.com/billpay/AccountSummary.do" $sUsername = "asd@asd.com" $sPassword = "mypass" $oIE = _IECreate($sURL) WinSetState($oIE, "", @SW_MAXIMIZE) $oForm = _IEFormGetCollection($oIE, 0) $oUsername = _IEFormElementGetObjByName($oForm, "username") $oPassword = _IEFormElementGetObjByName($oForm, "password") _IEFormElementSetValue($oUsername, $sUsername) _IEFormElementSetValue($oPassword, $sPassword) _IEFormSubmit($oForm) I hadn't noticed what he said. It's because I never use the _IEFormGetCollection() function, as you can see Edited October 31, 2007 by Nahuel
Klexen Posted October 31, 2007 Author Posted October 31, 2007 (edited) No problem, but brickoneer's solution is better, IMO: #include <IE.au3> $sURL = "https://service.cox.com/profile/Login.do?TARGET=-SM-https://service.cox.com/billpay/AccountSummary.do" $sUsername = "asd@asd.com" $sPassword = "mypass" $oIE = _IECreate($sURL) WinSetState($oIE, "", @SW_MAXIMIZE) $oForm = _IEFormGetCollection($oIE, 0) $oUsername = _IEFormElementGetObjByName($oForm, "username") $oPassword = _IEFormElementGetObjByName($oForm, "password") _IEFormElementSetValue($oUsername, $sUsername) _IEFormElementSetValue($oPassword, $sPassword) _IEFormSubmit($oForm) I hadn't noticed what he said. It's because I never use the _IEFormGetCollection() function, as you can see Thanks man! I just did this... #include <IE.au3> $sURL = "https://service.cox.com/profile/Login.do?TARGET=-SM-https://service.cox.com/billpay/AccountSummary.do" $sUsername = "" $sPassword = "" $oIE = _IECreate($sURL) $HWND = _IEPropertyGet($oIE, "hwnd") WinSetState($HWND, "", @SW_MAXIMIZE) _IEAction($oIE, "visible") _IELoadWait($oIE) $oForm = _IEFormGetCollection($oIE, 0) $oUsername = _IEGetObjByName($oIE, "username") $oPassword = _IEGetObjByName($oIE, "password") _IEFormElementSetValue($oUsername, $sUsername) _IEFormElementSetValue($oPassword, $sPassword) _IEFormSubmit($oForm) Edited October 31, 2007 by Klexen
Nahuel Posted October 31, 2007 Posted October 31, 2007 Just two things you should notice: _IEAction($oIE, "visible") _IELoadWait($oIE) They are pointless. _IECreate() will wait until the page has loaded before returning, so there's no need for _IELoadWait() and it will always be visible unless you tell it to create it hidden. So _IEAction($oIE, "visible") does nothing because it's already visible.
Blue_Drache Posted October 31, 2007 Posted October 31, 2007 _IEFormSubmit() works most times, yes. Good job. However, sometimes you HAVE to click the button. You'll get some values of your input box and/or button by using the _IETagNameGetCollection() function. $L_o_Inputs = _IETagNameGetCollection($L_oIE_CRU, "INPUT") $L_iInputCnt = @extended ConsoleWrite("Debug: Found " & $L_iInputCnt & " input tags" & @LF) Local $flagRFC = 0 If $L_iInputCnt Then For $L_oInput In $L_o_Inputs If $L_oInput.name = "rfcrAmt" And $flagRFC < 1 Then $L_oInput.value = $strRFCAmt ConsoleWrite("Debug: Updated RFCR Amt" & @LF) $flagRFC = 1 EndIf If $L_oInput.type = "submit" And $L_oInput.value = "Update" Then ConsoleWrite("Debug: Found Update button" & @LF) _IEAction($L_oInput, "click") ExitLoop EndIf Next EndIf Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
Klexen Posted October 31, 2007 Author Posted October 31, 2007 @Nahuel - Thanks for the tip, it's been a force of habit to do it that way. @Blue Drache - Thanks dude, that will really help in the future. @Brickoneer - Thanks a lot for the help!
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