Sign in to follow this  
Followers 0
UTA

How To Replace The Body-text Of An Embedded Ie-activex

5 posts in this topic

Hi,

IE offers a zoom functionality with IEFrames. I want to use this by replacing the whole HTML-body-code in an embedded ActiveX-Object with "<iframe style='zoom:50%' src='http://www.autoitscript.com' width='100%' height='100%'>". With this code, the autoit-website will be opened with a zoomfactor of 50%.

I tried it with this code:

#include <GUIConstants.au3>
$oIE = ObjCreate("Shell.Explorer.2")
$InternalBrowserGUI = GUICreate ('Test', 600, 400, @DesktopWidth-600-5, @DesktopHeight-400-30 , $WS_POPUP+$WS_BORDER, $WS_EX_TOPMOST)
$GUIActiveX      = GUICtrlCreateObj( $oIE, 1, 1, 600-2 , 400-2 )
GUISetState (@SW_SHOW, $InternalBrowserGUI)

MsgBox(0,'Message','1. Try...')
$oIE.document.write("<html><body><iframe style='zoom:50%' src='http://www.autoitscript.com' width='100%' height='100%'></body></html>")

MsgBox(0,'Message','2. Try...')
$oIE.document.write("<iframe style='zoom:50%' src='http://www.autoitscript.com' width='100%' height='100%'>")

MsgBox(0,'Message','3. Try...')
$oIE.document.body.innerHTML = "<iframe style='zoom:50%' src='http://www.autoitscript.com' width='100%' height='100%'>"

MsgBox(0,'Message','4. Try...')
$oIE.navigate('http://www.autoitscript.com')

While $oIE.busy
    sleep(50)
WEnd
MsgBox(0,'Message','Finished!')

Only the fourth (the normal) of my tests is working. All the other three versions doesn't.

I'm sure I am close to the solution but I semm to be blind....

Could some of you help me?

UTA

Share this post


Link to post
Share on other sites



This is all I could come up with to make it work.

#include <GuiConstants.au3>

$oIE = ObjCreate("Shell.Explorer.2")
$InternalBrowserGUI = GUICreate ('Test', 600, 400, @DesktopWidth/2-300, @DesktopHeight/2-200 , $WS_POPUP+$WS_BORDER, $WS_EX_TOPMOST)
$GUIActiveX = GUICtrlCreateObj( $oIE, 1, 1, 600-2 , 400-2 )
GUISetState ()

$oIE.GoHome()
Sleep(1000)
While ($oIE.document.readyState <> "complete") and ($oIE.document.readyState <> 4)
    Sleep(100)
WEnd
$shtml = "<iframe style='zoom:50%' src='http://www.autoitscript.com' width='100%' height='100%'>"
$oIE.document.body.innerHTML = $shtml

While 1
    sleep(100)
WEnd

Share this post


Link to post
Share on other sites

You are my big daddy! It works.

I made a few improvements but your version was the help i was looking for.

#include <GUIConstants.au3>

$oIE = ObjCreate("Shell.Explorer.2")
$InternalBrowserGUI = GUICreate ('Test', 600, 400, @DesktopWidth-600, @DesktopHeight-420 , $WS_POPUP+$WS_BORDER, $WS_EX_TOPMOST)
$GUIActiveX = GUICtrlCreateObj( $oIE, 1, 1, 600-2 , 400-2 )
GUISetState ()
$oIE.navigate("about:blank")
$shtml = "<iframe style='zoom:75%' src='http://www.autoitscript.com' width='100%' height='100%'>"
$oIE.document.body.innerHTML = $shtml
While 1
    sleep(100)
WEnd
MsgBox(0,'Message','Finished!')

Thanks!

Share this post


Link to post
Share on other sites

The trouble is that the Browser doesn't have a .document object until you navigate it somewhere...

This code works with IE.au3 functions and _IEBodyWriteHTML:

#include <GuiConstants.au3>
#include <IE.au3>

$oIE = ObjCreate("Shell.Explorer.2")
$InternalBrowserGUI = GUICreate ('Test', 600, 400, @DesktopWidth/2-300, @DesktopHeight/2-200 , $WS_POPUP+$WS_BORDER, $WS_EX_TOPMOST)
$GUIActiveX = GUICtrlCreateObj( $oIE, 1, 1, 600-2 , 400-2 )
GUISetState ()

_IENavigate($oIE, "about:blank")
$shtml = "<iframe style='zoom:50%' src='http://www.autoitscript.com' width='100%' height='100%'>"
_IEBodyWriteHTML($oIE, $sHTML)

While 1
    sleep(100)
WEnd

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

The trouble is that the Browser doesn't have a .document object until you navigate it somewhere...

This code works with IE.au3 functions and _IEBodyWriteHTML:

#include <GuiConstants.au3>
#include <IE.au3>

$oIE = ObjCreate("Shell.Explorer.2")
$InternalBrowserGUI = GUICreate ('Test', 600, 400, @DesktopWidth/2-300, @DesktopHeight/2-200 , $WS_POPUP+$WS_BORDER, $WS_EX_TOPMOST)
$GUIActiveX = GUICtrlCreateObj( $oIE, 1, 1, 600-2 , 400-2 )
GUISetState ()

_IENavigate($oIE, "about:blank")
$shtml = "<iframe style='zoom:50%' src='http://www.autoitscript.com' width='100%' height='100%'>"
_IEBodyWriteHTML($oIE, $sHTML)

While 1
    sleep(100)
WEnd

Dale

Never even thought about navigating to about:blank :think:

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