Sign in to follow this  
Followers 0
matbriseb

Using the IE.AU3 Catch event of a Internet explorer SUBMITFORM

22 posts in this topic

Using the IE.AU3

I would live to save te value of some input box when the submit button of the form is sent.

Is ther anyway to capt this event after that I will keep the value of the input box?

Thanks!

Share this post


Link to post
Share on other sites



Using the IE.AU3

I would live to save te value of some input box when the submit button of the form is sent.

Is ther anyway to capt this event after that I will keep the value of the input box?

Thanks!

Sure -- see here for an example: COM/OLE events in Internet explorer, make internet explorer talk to you script Options

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

Hi Dale, here is a question for you again :-) Not related to "event", but to "submit". Hope it is ok to post my question in this thread.

The below scripts fill user and password field and logs on automatically. You can use {CLICK} or {SUBMIT} to determine the "submit method"

E.g.

test.au3 "online.firstusa.com/bank/bolLogin.aspx" username passoword {SUBMIT}

But interestingly

test.au3 https://sourceforge.net/account/login.php username password {SUBMIT}

does not work. It looks like that the .submit method does something, but comes back immediately

test.au3 https://sourceforge.net/account/login.php username password {CLICK}

works.

Shouldn't "anyform.submit" always work?

I am clueless :-)

Cheers, Dave

ie.au3

Global $oButtonElement
Global $oPasswordForm
Global $PasswordFound = False

$Url      = $CmdLine[1]
$Username = $CmdLine[2]
$Password = $CmdLine[3]
    
$oIE=ObjCreate("InternetExplorer.Application")

With $oIE
    .Visible = True
    .Navigate($Url)
    Do
        Sleep(100)
    Until (.ReadyState = 4) and (.document.ReadyState = "complete")
EndWith

Sleep (500)


FormFiller ($oIE)
If $oIE.document.body.tagName = "FRAMESET" Then RecurseIntoFrames($oIE)


if $CmdLine[0] = 3  Then Exit

$Autotype = $CmdLine[4]

If $PasswordFound = False Then
    $ButtonPressed = MsgBox (1,"Warning", "No Password field found. Do you really want to continue?",10)
    If $ButtonPressed <> 1 Then
        Exit
    EndIf
EndIf

If StringInStr($Autotype, "{SUBMIT}") Then
    $Autotype = StringReplace($Autotype, "{SUBMIT}", "") 
    $SubmitEnabled = True
Else
    $SubmitEnabled = False
EndIf

If $SubmitEnabled = True and IsObj ($oPasswordForm) Then
   $oPasswordForm.submit()
EndIf

If StringInStr($Autotype, "{CLICK}") Then
    $Autotype = StringReplace($Autotype, "{CLICK}", "") 
    $CLickEnabled = True
Else
    $ClickEnabled = False
EndIf

If $ClickEnabled = True and IsObj ($oButtonElement) Then
   $oButtonElement.click()
EndIf


exit


Func FormFiller ($oObject)
    Local $oTmpButtonElement
    Local $oPasswordElement
    Local $oUserElement 

    $oForms = $oObject.document.forms
    For $oForm in $oForms
        $oPasswordElement   = 0
        $oUserElement      = 0
        $oTmpButtonElement  = 0
        $oInputs = $oForm.getElementsByTagName("input")
        For $oElement In $oInputs   
            Select
            Case $oElement.type = "submit" OR $oElement.type = "image"
              $oTmpButtonElement = $oElement
            Case $oElement.type = "password"
                $oElement.value = $Password
                $oElement.focus()
                $oPasswordElement = $oElement
                $PasswordFound = True
            Case $oElement.type = "text"
                $oElement.value = $Username
                $oUserElement = $oElement
            Case Else
            EndSelect
        Next
        If IsObj ($oPasswordElement) and IsObj ($oTmpButtonElement) Then
            $oButtonElement = $oTmpButtonElement
        EndIf 
        If IsObj ($oPasswordElement) Then
            $oPasswordForm = $oForm
        EndIf 
    Next
EndFunc


Func RecurseIntoFrames ($oObject)
    If IsObj($oObject) = 0 Then Return
    For $i = 0 to $oObject.document.parentwindow.frames.length-1
        $oFrame = $oObject.document.parentwindow.frames.item ($i)
        FormFiller ($oFrame) 
        RecurseIntoFrames ($oFrame)
    Next
Endfunc

Share this post


Link to post
Share on other sites

>>Shouldn't "anyform.submit" always work?

Actually, the .submit method VERY often does not work. The reason is that it is very common practice now to tie javascript functions to the onclick event of the submit button instead of doing a normal form submission -- the .submit method does not trigger this event.

I have come to see that it is so common to do this at this point that I would recommend using the .click on the submit button instead of .submit on the form all the time.

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

Hi Dale, thanks for your quick reply.

The problem with click is, that you have to find the right button first. There can be more than one button in a form

https://online.firstusa.com/bank/bolLogin.aspx

And sometimes the button is even located in a different form, for instance

www.ureach.com/home3/login6.htm

Finding the right button in a generic way, seems to be very difficult?

What I noticed is, that putting the focus into the password field and then send("{ENTER}") always works, but I would like to use DOM instead of sending keys. I thought submitting a form would be equal to hitting enter. But I guess that's not correct. Is there a way to "hit enter" via DOM?

Any ideas?

Thanks again for your time.

Dave

Share this post


Link to post
Share on other sites

Hi Dale, thanks for your quick reply.

The problem with click is, that you have to find the right button first. There can be more than one button in a form

https://online.firstusa.com/bank/bolLogin.aspx

And sometimes the button is even located in a different form, for instance

www.ureach.com/home3/login6.htm

Finding the right button in a generic way, seems to be very difficult?

What I noticed is, that putting the focus into the password field and then send("{ENTER}") always works, but I would like to use DOM instead of sending keys. I thought submitting a form would be equal to hitting enter. But I guess that's not correct. Is there a way to "hit enter" via DOM?

Any ideas?

Thanks again for your time.

Dave

Here's a discussion of this by someone who has put a lot of thought into form submission with the Enter key:

FORM submission and the ENTER key?

It seems that the behavior is inconsistently implemented and it may not always do what you want. For example, if there are two submit buttons on a form it will use the first. In your scenario, the first submit button could easily be something like "Get an Account" and the second could be what you want- "Login".

It is an interesting read and will open your eyes to more exceptions and corner cases than it will solutions.

I am really not a fan of this sort of generic operation - especially when you are using passwords. I worry about the many ways that you might expose your password in the wrong place to the wrong people and in plain text.

Keep working on your heuristics and you'll get better and better at it, but I don't think you can make it perfect.

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

Dale,

thanks for the quick answer!

By the way, when do you release a new version of ie.au3?

Cheers, Dave

Share this post


Link to post
Share on other sites

thanks for the quick answer!

By the way, when do you release a new version of ie.au3?

You're welcome.

I'm steadily working on a new version... I can't be more specific yet.

@matbriseb - thanks for the use of your thread :P


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

Can it capt every possible event because what i like to do is a kind of listener who will repoduce every active

take from a user.

In order,

My script will keep in mind every internet explorer windows open

Every link click

Every field value and every sumbit click

to repeat it whatever internet explorer action have been made!

Is it possible?

Thanks again Dale!

Share this post


Link to post
Share on other sites

Can it capt every possible event because what i like to do is a kind of listener who will repoduce every active

take from a user.

In order,

My script will keep in mind every internet explorer windows open

Every link click

Every field value and every sumbit click

to repeat it whatever internet explorer action have been made!

Is it possible?

Thanks again Dale!

Yes you can -- here is a snip from the Obj/COM Reference help:

If you don't know (for some reason) the names of the events, you can add a UDF with only the prefix. In this example: MyEvent_($Eventname).

When an event is received and no MYEvent_Eventname UDF exists, this function will be called instead and the name of the event will be placed in the variable $Eventname.

So you can have code like this:
$oEvt = ObjEvent($oIE, "events_")
Func events_($param)
    ConsoleWrite($param & @CR)
EndFunc

The function will be triggered on all events for the InternetExplorer.Application automation object.

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

Wow!!!! That's give me a lot a facility!!

Thanks again and again for your quick help!!!

Share this post


Link to post
Share on other sites

What is the IEEvent that can capt a link click and a checkbox selection?

Share this post


Link to post
Share on other sites

What is the IEEvent that can capt a link click and a checkbox selection?

I'm not certain I understand "capt a link click and a checkbox selection".

There is an onclick event for form and form element objects...

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

matbriseb, From the examples you have given, I'm hoping you're not writing a phishing/keylogger, are you?

Be aware that any passwords stored in your code are not very secure, especially if you are going to be automating online banking.

Share this post


Link to post
Share on other sites

matbriseb, From the examples you have given, I'm hoping you're not writing a phishing/keylogger, are you?

Be aware that any passwords stored in your code are not very secure, especially if you are going to be automating online banking.

No!! I'm using it because I have a big form to fill more than one time and the value are not always the same.

So I want to capt the action of a user and replicate those action for a certain number of time.

It's only for make a task easy!

Nothing bad!!

Share this post


Link to post
Share on other sites

I'm having some problem with a submit form that seem to activate a Jscript code.

Here is the exemple:

<input type="submit" name="Soumettre" value="Soumettre" id="soumettre" onclick="document.forms[0].actionButton.value = 'buttonsubmit'; " />

I already tried:

_IEFormSubmit($o_form)

and

$o_SubmitButton = _IEFormElementGetObjByName($o_form, "Soumettre")

$o_SubmitButton.click

_IELoadWait($oBrowser)

It's still not working!!

What can I do?

Share this post


Link to post
Share on other sites

I'm having some problem with a submit form that seem to activate a Jscript code.

Here is the exemple:

<input type="submit" name="Soumettre" value="Soumettre" id="soumettre" onclick="document.forms[0].actionButton.value = 'buttonsubmit'; " />

I already tried:

_IEFormSubmit($o_form)

and

$o_SubmitButton = _IEFormElementGetObjByName($o_form, "Soumettre")

$o_SubmitButton.click

_IELoadWait($oBrowser)

It's still not working!!

What can I do?

your logic looks valid with the .click method. "still not working" doesn't give much to go on however. What happens (or doesn't happen)? Are there error messages? Have you verified that $o_SubmitButton is a valid object variable?

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

your logic looks valid with the .click method. "still not working" doesn't give much to go on however. What happens (or doesn't happen)? Are there error messages? Have you verified that $o_SubmitButton is a valid object variable?

Dale

Sorry!!

The form seem to be submit but the same page is reload after that!

When I manually click on the "Soumettre" button, it's send me to the next page but with the ".click" the form just flash (reload).

I think it's because there is a validation of the field in the form with the onclick= in the html code

Share this post


Link to post
Share on other sites

Sorry!!

The form seem to be submit but the same page is reload after that!

When I manually click on the "Soumettre" button, it's send me to the next page but with the ".click" the form just flash (reload).

I think it's because there is a validation of the field in the form with the onclick= in the html code

I don't know what to tell you. Using .click on the object is identical to physically clicking it. Perhaps there is something else that makes the automated scenario diffent leading up to the .click? Is there a chance that there is more than one object with that name?

For any further assistance you'll need to create a reproducer that can be tested -- I have not other ideas at this point.

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

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