Sbarabau Posted June 10, 2010 Share Posted June 10, 2010 (edited) http://www.autoitscript.com/forum/index.php?showtopic=55282 On that topic is an example for "intercept" IE's events I tried several times to intercept the event "NewWindow3", but Internet Explorer crashes off until I kill the script with the task manager This is the script that I've made. I can not understand where I've wrong. #include <IE.au3> Local $oIE = _IECreate() ObjEvent($oIE,"IEEvent_","DWebBrowserEvents2"); Assign events to UDFs starting with IEEvent_ _IEPropertySet($oIE,'visible',1) _IENavigate($oIE,'www.google.com') While 1 Sleep(50) WEnd Func IEEvent_NewWindow3 ($ppDisp, $Cancel, $dwFlags, $bstrUrlContext, $bstrUrl) ConsoleWrite('New window to: '&$bstrUrlContext&@LF) EndFunc Here I found the information needed for the event "NewWindow3": http://msdn.microsoft.com/en-us/library/aa768337.aspx Edited June 10, 2010 by Sbarabau Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 10, 2010 Share Posted June 10, 2010 The first two parameters of that event are ByRef, and AutoIt doesn't have that capability. I doesn't work for me, but I don't get errors either. Maybe hitting the ByRef parameters keeps the event handler from being called? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
DaleHohm Posted June 10, 2010 Share Posted June 10, 2010 (edited) I can't explain why you don't see the NewWindow3 event... an expanded example below shows that other events are bing trapped but not this one. PSaltyDS makes an important point about byRef, but it should not prevent us from seeing the event, only from being able to cancel it. You may want to work up an example in vbscript and see if it behaves differently. Dale oops, forgot code: #include <IE.au3> $oIE = _IECreate("http://www.w3schools.com/html/html_links.asp") $oSink = ObjEvent($oIE,"IEEvent_","DWebBrowserEvents2"); Assign events to UDFs starting with IEEvent_ While 1 Sleep(50) WEnd Func IEEvent_NewWindow3 ($ppDisp, $Cancel, $dwFlags, $bstrUrlContext, $bstrUrl) ConsoleWrite('New window to: '&$bstrUrlContext&@LF) EndFunc Func IEEvent_ ($event) ConsoleWrite('Event: '&$event&@LF) EndFunc Edited June 10, 2010 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...
PsaltyDS Posted June 10, 2010 Share Posted June 10, 2010 Hmm... some Googling turned this up: In a VB6 application I use the WebBrowser Control (shdocvw.dll). I need tocheck the URL as a new window is being opened. The only way is to get theURL when the NewWindow3 event is fired. When I try to select the NewWindow3event in the IDE, a popup message told me: "Function or interface marked as restricted, or the function uses anAutomation type not supported in Visual Basic".Interface marked as restricted...? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Sbarabau Posted June 11, 2010 Author Share Posted June 11, 2010 I can't explain why you don't see the NewWindow3 event... an expanded example below shows that other events are bing trapped but not this one. PSaltyDS makes an important point about byRef, but it should not prevent us from seeing the event, only from being able to cancel it. You may want to work up an example in vbscript and see if it behaves differently. Dale oops, forgot code: #include <IE.au3> $oIE = _IECreate("http://www.w3schools.com/html/html_links.asp") $oSink = ObjEvent($oIE,"IEEvent_","DWebBrowserEvents2"); Assign events to UDFs starting with IEEvent_ While 1 Sleep(50) WEnd Func IEEvent_NewWindow3 ($ppDisp, $Cancel, $dwFlags, $bstrUrlContext, $bstrUrl) ConsoleWrite('New window to: '&$bstrUrlContext&@LF) EndFunc Func IEEvent_ ($event) ConsoleWrite('Event: '&$event&@LF) EndFunc I can't program in VB I can't also see the NewWindow and NewWindow2 events. I can't tell if it is a bug in AutoIt or a problem in the variables of the NewWindow3 event. How can I resolve this problem? Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 11, 2010 Share Posted June 11, 2010 So far, it looks to me like Microsoft doesn't want that event available without at least some kind of elevated privileges. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Sbarabau Posted June 12, 2010 Author Share Posted June 12, 2010 So far, it looks to me like Microsoft doesn't want that event available without at least some kind of elevated privileges. #RequireAdmin is enough?If not, how can I do this? Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 12, 2010 Share Posted June 12, 2010 #RequireAdmin is enough?If not, how can I do this?Don't know, haven't found anything explicit from MSDN about the problem. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
DaleHohm Posted June 12, 2010 Share Posted June 12, 2010 Note from above.... I suggested reproducing in VBScript, not VB. If you can code in AutoIt, a few minutes with a reference guide for VBScript on the internet should make you profient enough to replicate the code in VBScript. 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...
Sbarabau Posted June 13, 2010 Author Share Posted June 13, 2010 (edited) I tried so, but the event NewWindow3 is not detected. Set IEobject = WScript.CreateObject("InternetExplorer.Application","IEobject_") IEobject.Visible = True IEobject.Navigate2 "http://www.google.it" Do While IEobject.Visible WScript.Sleep 500 Loop Sub IEobject_BeforeNavigate2(pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel) Wscript.Echo "Going to:", URL Cancel = True End Sub Sub IEobject_NewWindow3(ppDisp, ByRef Cancel, bstrUrlContext, bstrUrl) Wscript.Echo "New window:", bstrUrl Cancel = True End Sub Edited June 13, 2010 by Sbarabau Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 13, 2010 Share Posted June 13, 2010 I tried so, but the event NewWindow3 is not detected. Set IEobject = WScript.CreateObject("InternetExplorer.Application","IEobject_") IEobject.Visible = True IEobject.Navigate2 "http://www.google.it" Do While IEobject.Visible WScript.Sleep 500 Loop Sub IEobject_BeforeNavigate2(pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel) Wscript.Echo "Going to:", URL Cancel = True End Sub Sub IEobject_NewWindow3(ppDisp, ByRef Cancel, bstrUrlContext, bstrUrl) Wscript.Echo "New window:", bstrUrl Cancel = True End Sub VBScript can use ByRef in the event, but all variables are type VARIANT, so IE won't recognize changes to Cancel because it doesn't want a variant returned. As Dale said before, this should only keep you from using Cancel in VBScript, and not prevent the event from firing. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Sbarabau Posted June 14, 2010 Author Share Posted June 14, 2010 ok, but how can I then receive the event NewWindow3 in AutoIt? Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 14, 2010 Share Posted June 14, 2010 ok, but how can I then receive the event NewWindow3 in AutoIt?Well, there's the catch: The same way you would in VBScript -- if it worked in VBScript -- which it doesn't. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Sbarabau Posted June 17, 2010 Author Share Posted June 17, 2010 Nobody else can help me? Link to comment Share on other sites More sharing options...
Sbarabau Posted June 18, 2010 Author Share Posted June 18, 2010 Up! Link to comment Share on other sites More sharing options...
Sbarabau Posted June 19, 2010 Author Share Posted June 19, 2010 Up Link to comment Share on other sites More sharing options...
Sbarabau Posted June 23, 2010 Author Share Posted June 23, 2010 Up Link to comment Share on other sites More sharing options...
Juvigy Posted June 23, 2010 Share Posted June 23, 2010 It is best to think of something else to use instead of this NewWindow3 event. What exactly do you want to do in your script? Link to comment Share on other sites More sharing options...
DaleHohm Posted June 23, 2010 Share Posted June 23, 2010 The point of trying it in VBScript is that if it doesn't work there, you can take the issue to the Microsoft Community discussion boards or log a problem report with Microsoft (and if it doesn't work in VBScript, it is not an AutoIt problem). There, you will find hundreds if not thousands of people who may be able to help you, in addition to the developers who have access to the source code and having a vested interest in making it work as documented (here there are are only a handful). Unless you choose an alternate approach as Juvigy suggests, pushing harder here will no be fruitful. 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...
Sbarabau Posted June 27, 2010 Author Share Posted June 27, 2010 It is best to think of something else to use instead of this NewWindow3 event.What exactly do you want to do in your script?I created a small multitab browser based on IEWhen you click an external link then creates a new window, but belonging to IEI would then intercept the event NewWindow3 to prevent the opening of the new window and direct it in a new tab in my browserThe point of trying it in VBScript is that if it doesn't work there, you can take the issue to the Microsoft Community discussion boards or log a problem report with Microsoft (and if it doesn't work in VBScript, it is not an AutoIt problem). There, you will find hundreds if not thousands of people who may be able to help you, in addition to the developers who have access to the source code and having a vested interest in making it work as documented (here there are are only a handful).Unless you choose an alternate approach as Juvigy suggests, pushing harder here will no be fruitful.DaleThe solution to communicate this problem to Microsoft is feasible.How can I do this? 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