Jump to content

_IECreateEmbedded in child window: script freezing


rogdog
 Share

Recommended Posts

After many hours of searching the forum and head scratching I have failed to work out why the following script freezes.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

;_IEErrorHandlerRegister ()

; Create main window
$hParent = GUICreate("My GUI Tab",600,600)
$idMsgbox = GUICtrlCreateButton("MSGBOX",3,5,100,25)
GUISetState(@SW_SHOW,$hParent)

; create child window
; If next 2 lines are commented out then script does not freeze 
$hChild   = GuiCreate("Child",550,550,0,30,$WS_CHILD,-1,$hParent)
GUISetState(@SW_SHOW,$hChild)

; Create Embbedded IE Browser
$oIE = _IECreateEmbedded ()
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 500, 500)
$Event = ObjEvent($oIE, "_WebEvent_", "DWebBrowserEvents")

;_IENavigate ($oIE, 'about:blank') 
_IENavigate ($oIE, 'www.bbc.co.uk') 

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idMsgbox
            MsgBox(262144,0,"Button Pressed")
    EndSwitch
WEnd

Func _WebEvent_($EventName)
    ConsoleWrite($EventName&@crlf)
    ; MsgBox causes script to freeze if child windows has been created
    if $EventName = "DownloadBegin" then MsgBox(262144,0,$EventName)
EndFunc

The script seems to freeze after the fist MsgBox is dsiplayed in the _WebEvent() function.

Also, the problem only occurs if the child GUI is created. If the child GUI is commented out so that the embedded browser is created directly in the parent GUI then then the script is OK.

Has any one got a fix for me please.

Edited by rogdog
My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic]
Link to comment
Share on other sites

After many hours of searching the forum and head scratching I have failed to work out why the following script freezes.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

;_IEErrorHandlerRegister ()

; Create main window
$hParent = GUICreate("My GUI Tab",600,600)
$idMsgbox = GUICtrlCreateButton("MSGBOX",3,5,100,25)
GUISetState(@SW_SHOW,$hParent)

; create child window
; If next 2 lines are commented out then script does not freeze 
$hChild   = GuiCreate("Child",550,550,0,30,$WS_CHILD,-1,$hParent)
GUISetState(@SW_SHOW,$hChild)

; Create Embbedded IE Browser
$oIE = _IECreateEmbedded ()
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 500, 500)
$Event = ObjEvent($oIE, "_WebEvent_", "DWebBrowserEvents")

;_IENavigate ($oIE, 'about:blank') 
_IENavigate ($oIE, 'www.bbc.co.uk') 

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idMsgbox
            MsgBox(262144,0,"Button Pressed")
    EndSwitch
WEnd

Func _WebEvent_($EventName)
    ConsoleWrite($EventName&@crlf)
    ; MsgBox causes script to freeze if child windows has been created
    if $EventName = "DownloadBegin" then MsgBox(262144,0,$EventName)
EndFunc

The script seems to freeze after the fist MsgBox is dsiplayed in the _WebEvent() function.

Also, the problem only occurs if the child GUI is created. If the child GUI is commented out so that the embedded browser is created directly in the parent GUI then then the script is OK.

Has any one got a fix for me please.

You have blocked the event handler by showing the message box, and while that is displayed there will be more events wanting to call that function. So you could try this.

$hParent = GUICreate("My GUI Tab",600,600)
$idMsgbox = GUICtrlCreateButton("MSGBOX",3,5,100,25)
GUISetState(@SW_SHOW,$hParent)

; create child window
; If next 2 lines are commented out then script does not freeze
$hChild   = GuiCreate("Child",550,550,0,30,$WS_CHILD,-1,$hParent)
GUISetState(@SW_SHOW,$hChild)

; Create Embbedded IE Browser
$oIE = _IECreateEmbedded ()
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 500, 500)
$Event = ObjEvent($oIE, "_WebEvent_", "DWebBrowserEvents")

;_IENavigate ($oIE, 'about:blank')
_IENavigate ($oIE, 'www.bbc.co.uk')

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idMsgbox
            MsgBox(262144,0,"Button Pressed")
    EndSwitch
    if $webEv <> '' Then
        MsgBox(262144,0,$webEv)
        $webEv = ''
    EndIf
    
        
WEnd

Func _WebEvent_($EventName)
    ConsoleWrite($EventName&@crlf)
   ; MsgBox causes script to freeze if child windows has been created
   ;if $EventName = "DownloadBegin" then MsgBox(262144,0,$EventName)
    if $EventName = "DownloadBegin" then $webEv = $EventName
EndFunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hi Martin,

Many thanks for your tip. I have tried what you suggested but the script still hangs once the first MsgBox has appeared and I try an click on a link in the embedded web browser.

:)

My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic]
Link to comment
Share on other sites

Hi Martin,

Many thanks for your tip. I have tried what you suggested but the script still hangs once the first MsgBox has appeared and I try an click on a link in the embedded web browser.

:)

Yes, I'm afraid I don't know the answer. If you comment out the line

$Event = ObjEvent($oIE, "_WebEvent_", "DWebBrowserEvents")

it makes no difference.

If you press the message box button, and while the message box is displayed you click on a link then it freezes as you say.

It needs someone with more knowledge and understanding of the IE udf to help.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Hi Martin,

Thanks for having a look. Hopefully somebody else may be able to solve this one.

My Scripts[topic="73325"]_ReverseDNS()[/topic]Favourite scripts by other members[topic="81687"]SNMP udf[/topic][topic="70759"]Using SNMP - MIB protocol[/topic][topic="39050"]_SplitMon:Section off your monitor!, split your monitor into sections for easy management[/topic][topic="73425"]ZIP.au3 UDF in pure AutoIt[/topic][topic="10534"]WMI ScriptOMatic tool for AutoIt[/topic][topic="51103"]Resources UDF embed/use any data/files into/from AutoIt compiled EXE files[/topic]
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...