Sign in to follow this  
Followers 0
Juvigy

IE embedded + tabs issue

6 posts in this topic

Hi Guys,

I am trying to create a embedded in a GUI IE and would like to

use the "oIE.Navigate2("www.dir.bg", 2048)" method which should create a new tab.

But it doesnt work with embedded IE. It doesnt work with the _IECreateEmbed2 custom

function too (credit goes to zackrspv ).

This forks for me every time:

#include <IE.au3>
$oIE = _IECreate("www.google.com")
$oIE.navigate2("www.autoitscript.com", 2048)

This doesnt work :

include <WinAPI.au3>
#include <Constants.au3>
#include <IE.au3>
Local $pid, $hHandle, $hGUI, $sURL, $xHeight, $xWidth
$sURL = "about:blank"
$xWidth = 800
$xHeight = 600
$hGUI = GUICreate("Test", $xWidth, $xHeight)
$oIE = _IECreateEmbed2(500, 500, 10, 10, $hGUI)
_IENavigate($oIE, "www.google.com")
MsgBox(0,"","")
$oIE.Navigate2("www.dir.bg", 2048)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_RESIZED, $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE
            $newSize = WinGetClientSize($hGUI)
            _WinAPI_MoveWindow($hHandle, 0, 0, $newSize[0], $newSize[1], True)
        Case $GUI_EVENT_CLOSE
            ExitLoop
EndSwitch
WEnd
_IEQuit($oIE)

Func _IECreateEmbed2($xWidth, $xHeight, $iX, $iY, $hGUI)
    $pID = Run(@ProgramFilesDir & "\internet explorer\iexplore.exe -k " & $sURL, "", @SW_HIDE)
    Do
        Sleep(100)
    Until Not (ProcessExists($pID) = 0)
    $hHandle = _ProcessGetHWnd($pID)
    Do
        $oIElocal = _IEAttach($hHandle, "HWND")
        Sleep(100)
    Until $oIElocal <> 0
    GUISetState(@SW_SHOW, $hGUI)
    _WinAPI_SetParent($hHandle, $hGUI)
    _WinAPI_MoveWindow($hHandle, $iX, $iY, $xWidth, $xHeight, True)
    _WinAPI_SetWindowLong($hHandle, $GWL_STYLE, BitOR($WS_CHILD, $WS_VISIBLE))
    Return $oIElocal
EndFunc   ;==>_IECreate2

Func _ProcessGetHWnd($iPid, $sTitle = "", $iTimeout = 2000)
    Local $aWin
    While 1
        $aWin = WinList($sTitle)
        For $i = 1 To $aWin[0][0]
            If $iPid = WinGetProcess($aWin[$i][1]) Then
                Return $aWin[$i][1]
            EndIf
        Next
        Sleep(500) ; add a timer here
    WEnd
    SetError(1)
    Return 0
EndFunc   ;==>_ProcessGetHWnd

Dale claims that it should be something wrong with my IE configuaration/system settings but i cant find anything wrong.

IE 7.0.5730.13 XP SP2. Please help.

Share this post


Link to post
Share on other sites



I told you it was a problem with your configuration because you said that this failed:

#include <IE.au3>
$oIE = _IECreate("www.google.com")
$oIE.navigate2("www.autoitscript.com", 2048)

Now you are saysing that that works (forks) for you every time. Which is it?

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ops , sorry about that.Miss-understanding.

#include <IE.au3> 
$oIE = _IECreate("www.google.com") 
$oIE.navigate2("www.autoitscript.com", 2048)

The above works for me every time. My other code doesnt work.+

Fails on $oIE.navigate2("www.autoitscript.com", 2048)

Is it working for you?

Edited by Juvigy

Share this post


Link to post
Share on other sites

Tabbed browsing doesn't work in kiosk mode for the same reason that it doesn't work in the WebBrowser control - the window dressings that would display them are unavailable.

When I sent you off to look for _IECreate2, the idea is that you would create your own tabbed GUI interface and manage the display and hiding of multiple _IECreate2 windows yourself. Tabs in IE are not available to you. The reason for not using this method instead of _IECreateEmbedded and GUICtrlCreateObj is that GUICtrlCreateObj messes up on keyboard event delivery when used multiple times in a GUI.

(note to future searchers... he changed the name of _IECreate2 to _IECreateEmbed2 in his example - if you are trying to find its thread, look for _IECreate2).

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

Share this post


Link to post
Share on other sites

I failed to embed this in a Tab control. Is there a way or i should play with the "visible" property of several embedded IE objects?

Also when clicking a link i would have to cancel navigation and open the link in a new window - new IE object ? How can i do that best - tracking events like "beforenavigate" ?

!0x for the replies.

Share this post


Link to post
Share on other sites

Because of the way AutoIt handles COM events, you cannot cancel one - you need to think of AutoIt being notified of events rather than being in the event processing stream. For this reason, you'll need to inject Javascript into the page if this is a requirement. See _IEHeadInsertEvenetScript() or try this method:

Func IEHeadInsertScript($o_object, $s_script)
    Local $o_head, $o_element
    $o_head = _IETagNameGetCollection($o_object, "head", 0)
    $o_element = $o_object.document.createElement('script')
    $o_element.type = 'text/javascript'
    $o_element.text = $s_script
    Return $o_head.appendChild($o_element)
EndFunc   ;==>IEHeadInsertScript

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

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