Helena Posted November 12, 2005 Share Posted November 12, 2005 About COM/OLE, I discover here a very good functions spécially with internet explorer automation but all of themuses 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 messageIf there is no possibility ? do you have an other idea without using a lot of CPU and looping? Link to comment Share on other sites More sharing options...
DaleHohm Posted November 12, 2005 Share Posted November 12, 2005 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 Link to comment Share on other sites More sharing options...
Helena Posted November 12, 2005 Author Share Posted November 12, 2005 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.Daledid you have an exemple with form submit event ? i'll try right now and post if it works Link to comment Share on other sites More sharing options...
Helena Posted November 12, 2005 Author Share Posted November 12, 2005 here is my first test. it not work #include <IE.au3>$oIE =_IEAttach("http://edit.europe.yahoo.com/config/mail?.intl=fr","url")$oForm = _IEFormGetObjByName($oIE, "login_form")$oEvt = ObjEvent($oForm, "IEEvent_")Func IEEvent_onsubmit() MsgBox(1,"","the form is submitted...")EndFunc Link to comment Share on other sites More sharing options...
DaleHohm Posted November 12, 2005 Share Posted November 12, 2005 did you have an exemple with form submit event ? i'll try right now and post if it worksIf 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 Link to comment Share on other sites More sharing options...
Helena Posted November 12, 2005 Author Share Posted November 12, 2005 Hoops! May be i forgot to do a sleep to wait for Objct event (not work again )#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 Link to comment Share on other sites More sharing options...
DaleHohm Posted November 12, 2005 Share Posted November 12, 2005 (edited) Hoops! May be i forgot to do a sleep to wait for Objct event (not work again )#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 EndFuncEdit: 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 November 12, 2005 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 Link to comment Share on other sites More sharing options...
Helena Posted November 12, 2005 Author Share Posted November 12, 2005 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)WEndFunc 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)ExitEndFuncGreat work Dale ! thinks! Link to comment Share on other sites More sharing options...
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