Sign in to follow this  
Followers 0
TerarinKerowyn

_Login, comment if you find something

4 posts in this topic

#1 ·  Posted (edited)

#Region Function _Login()
;==================================================================
; Function Name:  _Login()
;
; Description   :  Attempt to login to a site
; Parameter(s)   :  None
; Requirement(s) :  None
; Return Value(s):  On Success - Returns a 
;                  On Failure - Returns an -1 and sets @Error
;                       @Error=1 $o---- is not a Object
; Author         :  Terarin Kerowyn
; Note(s)       :  If you are trying to enter more stuff you need to add another IsObj so it checked on the Login Check
;    You can edit them with:
;     Tagname
;     InnerHTML
;     InnerText
;     OuterHTML
;     OuterText
;     Title
;     Id
; Link       ;  [url="http://www.autoitscript.com/forum/index.php?showtopic=73922"]http://www.autoitscript.com/forum/index.php?showtopic=73922[/url]
; Example     ;  Yes
;==================================================================
Func _Login()
$sEmail = "Enter Your Text Here" 
$sPassword = "Enter Your Text Here" 

$oElements = _IETagNameAllGetCollection($oIE)
For $oElement In $oElements
  If StringInStr($oElement.title, "Log In") Then
   $oLogin = $oElement
  ElseIf StringInStr($oElement.id, "Email") Then
   $oEmail = $oElement
  ElseIf StringInStr($oElement.id, "Password") Then
   $oPassword = $oElement
  EndIf
Next 


  If IsObj($oEmail) And IsObj($oPassword) And IsObj($oLogin) Then 
    _IEFormElementSetValue($oEmail, $sEmail)
    _IEFormElementSetValue($oPassword, $sPassword)
    _IEAction($oLogin, "click")
    _IELoadWait($oIE)
    Return 1
  Else
    MsgBox(0, "Not Found", "Login Is Not Found")
    SetError(1)
    Return -1
  EndIf
EndFunc
#EndRegion

Edited by TerarinKerowyn

Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Share this post


Link to post
Share on other sites



I don't really understand your question, but looked at your code and decided to rewrite it a bit to demonstrate a couple of concepts.

First, you already have an object reference to the Input fields as you loop through the collection, so there is no need to get a new one. Second, all of the fields must be in the same form in order for this to work for you, so this version scopes the search within forms.

Local $fFoundAll = False
$oForms = _IEFormGetCollection($oIE)
For $oFrom In $oForms
    $oInputs = _IETagNameGetCollection($oForm, "input")
    For $oInput In $oInputs
        If $oInput.type = ("text" Or "password" Or "image") Then
            $oForm = $oInput.form
            If StringInStr($oInput.name, "Email") Then
                $oEmail = $oInput
            ElseIf StringInStr($oInput.name, "Password") Then
                $oPassword = $oInput
            ElseIf StringInStr($oInput.name, "Login") Then
                $oLogin = $oInput
            EndIf
        EndIf
    Next
    If IsObj($oEmail) And IsObj($oPassword) And IsObj($oLogin) Then 
        $fFoundAll = True
        ExitLoop
    EndIf
Next

If $fFoundAll Then
    _IEFormElementSetValue($oEmail, $sEmail)
    _IEFormElementSetValue($oPassword, $sPassword)
    _IEAction($oLogin, "click")
    _IELoadWait($oIE)
Else
    MsgBox(0, "Not Found", "Login Form Not Found")
EndIf

Can you restate your question, if you still have one, in light of this revised code?

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

I'm sorry, sentences like the following just make no sense to me:

The thing with the _IEFormGetCollection fails is the Login when they choose that to be a individual entity apart from the Form.

You'll need to explain yourself better and more coherently.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Perhaps this version of the script will work better at the top as I put all the corrections on there


Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

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