Sign in to follow this  
Followers 0
Helena

COM/OLE events in Internet explorer

8 posts in this topic

About COM/OLE, I discover here a very good functions spécially with internet explorer automation but all of them

uses one-way communcation. You 'ask' the Object for any properties or results from a Method.

However a COM Object can also 'talk back' to your script when it suits it.

Instead of writing a kind of loop, asking the Object if something interesting has happened, you can let the Object itself call a specific UDF in your script.

Meanwhile you can do other things in your script (almost) simultaneously.

so my question is: how we can get IE events when it happens ? for exemple: when the user submit a form in a web page, IE objects (the form object) should send to our script this event message

If there is no possibility ? do you have an other idea without using a lot of CPU and looping?

Share this post


Link to post
Share on other sites



That's what the ObjEvent() command is all about. See the helpfile in the beta -- there is docuemtnation for it in both the general Obj/COM function reference section and the section specific to ObjEvent.

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

That's what the ObjEvent() command is all about. See the helpfile in the beta -- there is docuemtnation for it in both the general Obj/COM function reference section and the section specific to ObjEvent.

Dale

did you have an exemple with form submit event ? i'll try right now and post if it works

Share this post


Link to post
Share on other sites

did you have an exemple with form submit event ? i'll try right now and post if it works

If you search the forums for ObjEvent you'll find some examples, but none specific to that event I think (there are so many different events, but they all work in a similar fashion).

Give it a try and post your code if you are having trouble with specifics on what you've tried and why you are haing trouble and you'll probably get some help.

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

Hoops! May be i forgot to do a sleep to wait for Objct event (not work again B) )

#include <IE.au3>

$oIE =_IEAttach("http://edit.europe.yahoo.com/config/mail?.intl=fr","url")

$oForm = _IEFormGetObjByName($oIE, "login_form")

$oEvt = ObjEvent($oForm, "IEEvent_")

sleep(1000*20)

Func IEEvent_onsubmit()

MsgBox(1,"","the form is submitted...")

EndFunc

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Hoops! May be i forgot to do a sleep to wait for Objct event (not work again B) )

#include <IE.au3>

$oIE =_IEAttach("http://edit.europe.yahoo.com/config/mail?.intl=fr","url")

$oForm = _IEFormGetObjByName($oIE, "login_form")

$oEvt = ObjEvent($oForm, "IEEvent_")

sleep(1000*20)

Func IEEvent_onsubmit()

MsgBox(1,"","the form is submitted...")

EndFunc

This works (you need an idle loop)
#include <IE.au3>

$oIE =_IECreate()
_IENavigate($oIE, "http://www.google.com")
$oForm = _IEFormGetObjByName($oIE, "f")
$oEvt = ObjEvent($oForm, "IEEvent_")

While 1
    sleep(100)
WEnd

Func IEEvent_onsubmit()
    MsgBox(1,"","the form is submitted...")
    Exit
EndFunc

Edit: put an exit in the script so that you can get out

Edit: script didn't work at all -- had _IEAttach where I had intended an _IECreate() and _IENavigate() -- fixed

Dale

Edited by DaleHohm

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

It works as a charm !

here is my script with yahoo mail (french site)

#include <IE.au3>

$oIE =_IEAttach("http://edit.europe.yahoo.com/config/mail?.intl=fr","url")

$oForm = _IEFormGetObjByName($oIE, "login_form")

$oEvt = ObjEvent($oForm, "IEEvent_")

While 1

sleep(100)

WEnd

Func IEEvent_onsubmit()

;MsgBox(1,"","the form is submitted...")

$o_login = _IEFormElementGetObjByName($oForm, "login")

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

MsgBox(1,"",$o_login.value & @CRLF & $o_password.value)

Exit

EndFunc

Great work Dale ! thinks!

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