Jump to content

"Browser" crashes on Back, Forward buttons


Recommended Posts

This code is no rocket science, but browser crashes if Back or Forward button is clicked, given that nothing has been navigated to. I found a suggestion by Microsoft, but can't make heads or tails of it, and can't figure out how to implement the suggestion in AutoIt.

http://msdn2.microsoft.com/en-us/library/a...090(VS.85).aspx

#include <GUIConstants.au3>
#include <IE.au3>
; Simple example: Embedding an Internet Explorer Object inside an AutoIt GUI
;
; See also: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp

$oIE = ObjCreate("Shell.Explorer.2")
Opt("GuiResizeMode", $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM)

; Create a simple GUI for our output
$gui = GUICreate ( "Embedded Web control Test", 640, 580,(@DesktopWidth-640)/2, (@DesktopHeight-580)/2, BitOr($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
$client = WinGetClientSize($gui)
$GUIActiveX      = GUICtrlCreateObj   ( $oIE,   1, 30 , $client[0], $client[1]-30)
Opt("GuiResizeMode", $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT+$GUI_DOCKLEFT)

$GUI_Button_Back    = GuiCtrlCreateButton   ("Back",     1, 1, 100,  30)
$GUI_Button_Forward = GuiCtrlCreateButton   ("Forward", 100, 1, 100,  30)
$GUI_Button_Home    = GuiCtrlCreateButton   ("Home",    200, 1, 100,  30)
$GUI_Button_Stop    = GuiCtrlCreateButton   ("Stop",    300, 1, 100,  30)

GUISetState ()    ;Show GUI

$oIE.navigate("google.com")

While 1

    $msg = GUIGetMsg()
        if $oIE.busy=0 Then
            $title = $oIE.document.title
            WinSetTitle($gui, "", $title)
        EndIf
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            $oIE.navigate("http://www.autoitscript.com")
        Case $msg = $GUI_Button_Back
            $oIE.GoBack
        Case $msg = $GUI_Button_Forward
            $oIE.GoForward
        Case $msg = $GUI_Button_Stop
            $oIE.Stop
    EndSelect
    
Wend

GUIDelete ()

Exit
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...