ktoya Posted March 26, 2014 Share Posted March 26, 2014 Hi, I have a problem when I want to handle the click event in a embedded IE: when I click the link the GUI, it will start a real IE to open the link. I need it to be opened in another GUI embedded IE, is it possible? Link to comment Share on other sites More sharing options...
DW1 Posted March 26, 2014 Share Posted March 26, 2014 (edited) Well, I was going to suggest that you capture the NewWindow3 event from the browser and open the link yourself, however, I can't seem to cancel the new window from opening. Maybe somebody can fix this to where the $Cancel = True stops the window from opening... seems like it should, but I must be doing something wrong there. This code will open any link that is sent to a new window, in the embedded browser itself. That being said, for some reason it is not cancelling the new window, so you end up with both. I'm still trying to fix that part. EDIT: See working code in next post. Edited March 26, 2014 by DW1 AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Solution DW1 Posted March 26, 2014 Solution Share Posted March 26, 2014 Okay, so Volatile was the key! Volatile will allow the event function to fire synchronous so we can make our change to Cancel. Thank you Trancexx for the Volatile keyword! The following should cancel any new window calls and send the URL that was going to be opened in them to the embedded IE. #include <GUIConstantsEx.au3> #include <IE.au3> Global $oIE = _IECreateEmbedded() ObjEvent($oIE, "_Evt_", "DWebBrowserEvents2") $hGUI = GUICreate("Test", 1000, 500) GUICtrlCreateObj($oIE, 10, 10, 980, 480) GUISetState(@SW_SHOW) _IENavigate($oIE, "http://www.w3schools.com/html/tryit.asp?filename=tryhtml_link_target", 0) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Volatile Func _Evt_NewWindow3($ppDisp, ByRef $Cancel, $dwFlags, $bstrUrlContext, $bstrUrl) ;Any link being sent to a new window will be canceled and directed back to the embedded IE object ConsoleWrite("NewWindow3 attempted to open a new window @ " & $bstrUrl & @CRLF) _IENavigate($oIE, $bstrUrl, 0) $Cancel = True EndFunc ;==>_Evt_NewWindow3 AutoIt3 Online Help 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