maniootek

Internet Explorer - set window size according to content

2 posts in this topic

Is there any way to change IE window size according to its content size?

#include <IE.au3>

$oIE = _IECreate()
_IEBodyWriteHTML($oIE, '<table id="mytable"><tr><td style="white-space:nowrap; border: 1px solid black;">This is some text inside table row without space. I want to set internet explorer window size according to size of this table</td><tr></table>')
$oTable = _IEGetObjById($oIE, "mytable")
$width = _IEPropertyGet($oTable, "width")
$height = _IEPropertyGet($oTable, "height")
WinMove(_IEPropertyGet($oIE, "hwnd"), "", default, default, $width+150, $height+150)

In this example I have added 150 pixel to width and 150 pixel to height to my my table visible but I am looking for perfect solution which set the size of IE window perfectly to its content. Any idea?

Share this post


Link to post
Share on other sites



#2 ·  Posted

Hi @maniootek.

This is as close as i could get it. Hope it helps you :)

#include <IE.au3>

$oIE = _IECreate()
_IEBodyWriteHTML($oIE, '<table id="mytable"><tr><td style="white-space:nowrap; border: 1px solid black;">This is some text inside table row without space. I want to set internet explorer window size according to size of this table asdjalskdjsalkjdalksjdlk</td><tr></table>')
$iWidthMax = 0
For $oNode In $oIE.document.body.children
    $iWidthMax = ($oNode.offsetLeft + $oNode.offsetWidth)>$iWidthMax?($oNode.offsetLeft + $oNode.offsetWidth):$iWidthMax
Next
$oIE.width = $iWidthMax + ($oIE.width-$oIE.document.body.offsetWidth)

 

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