Sign in to follow this  
Followers 0
wisheu

Need help with Mozilla.Browser object

2 posts in this topic

#1 ·  Posted (edited)

Hello,

I'm playing a little bit with the ActiveX control of Mozilla and I've coded a little example, which works great, except on exit... Then it crashes... Perhaps someone could help me...

I'm using the latest AutoIt Beta.

Oh! And I forgot one big thing... This ActiveX-object uses the same syntax like the Shell.Explorer object!

You could even use the docs for it under: 'http://msdn.microsoft.com/workshop/browser/WebBrowser/WebBrowser.asp'

; Mozilla ActiveX Control - Test
; More details under 'http://www.iol.ie/~locka/mozilla/control.htm'
; You have to download and install this package: 'http://www.iol.ie/~locka/mozilla/MozillaControl177.exe'
; You have to open a DOS prompt, change to your Mozilla bin directory (e.g. 'cd c:\program files\Mozilla ActiveX Control v1.7.7')
; You have to execute 'regsvr32 mozctlx.dll'

#include <GUIConstants.au3>

$oMyError = ObjEvent("AutoIt.Error","MyError")
$oMozilla = ObjCreate("Mozilla.Browser")

; A simple error handler
Func MyError() 
    Local $HexNumber = hex ($oMyError.number, 8) 
    MsgBox (4096, "COM Error: " & $HexNumber & ", Source: " & $oMyError.source & ", Description: " & $oMyError.description, 1)   
Endfunc

; Create a simple GUI for our output
GUICreate ( "Embedded Mozilla-Webbrowser", 640, 580,(@DesktopWidth-640)/2, (@DesktopHeight-580)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj ( $oMozilla, 10, 40 , 600 , 360 )
$GUI_Button_Back = GuiCtrlCreateButton ("Back", 10, 420, 100, 30)
$GUI_Button_Forward = GuiCtrlCreateButton ("Forward", 120, 420, 100, 30)
$GUI_Button_Stop = GuiCtrlCreateButton ("Stop", 230, 420, 100, 30)

; Show GUI
GUISetState ()

; Navigate to www.microsoft.com
$oMozilla.navigate("http://www.microsoft.com")

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Back
            $oMozilla.GoBack
        Case $msg = $GUI_Button_Forward
            $oMozilla.GoForward
        Case $msg = $GUI_Button_Stop
            $oMozilla.Stop
    EndSelect
Wend

GUIDelete ()
Exit

Best regards

Michael

Edited by wisheu

Share this post


Link to post
Share on other sites



After endless searching I found a solution!

When I add '$oMozilla = 0' befor the 'GUIDelete ()' command it works without an error... Someone should mention this method of releasing an object in the help files!

Best regards

Michael

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