Jump to content

Internet Explorer - set window size according to content


 Share

Recommended Posts

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?

Link to comment
Share on other sites

  • 2 weeks later...

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)

 

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...