3

If I run the following code:

local $oBrowser = _IECreate("www.mywebsite.com")
local $oHTMLWindow = _IEAttach("Text In Title", "embedded")

I get two different behaviors (depending on Internet Explorer's protected mode configuration).

  • Protected Mode OFF - _IECreate() (followed by _IENavigate() inside) creates 2 iexplore.exe processes (one is the container, the other running tabs). I can then get the handle on my $oHTMLWindow variable.

  • Protected Mode ON - _IECreate() (followed by _IENavigate() inside) creates 3 iexplore.exe processes. One of low integrity (this is the protected mode part as expected). The thing is that this process then fails.

Is that the integrity level mechanism preventing me from getting the handle? How do I work around it?

MrLeeh
  • 5,321
  • 6
  • 33
  • 51
Tal
  • 398
  • 4
  • 19

1 Answers1

0

I had a similar issue with trying to get a handle to intranet sites because they seem to want to open in a different ie process and the handle to the original process seems to get lost. My workaround was to append a random string to the end of the website url (and hope that the server didn't care about this) and then try to attach to the internet explorer window with that same random url. It is kind of ugly but seems to work consistently for me.

#include <File.au3>
#include <IE.au3>

$url = 'https://www.mywebsite.com/'
; using a random string to ensure that we will attach to the IE instance that we created and not some other random one
$randomstring = StringTrimLeft(_TempFile('.','',''),2)
$randomurl = $url & '?' & $randomstring

_IECreate($randomurl)

$timer = TimerInit()
Do
    if TimerDiff($timer)/1000 >= 10 then
        ConsoleWrite('timeout' & @CRLF)
        Exitloop
    EndIf
    sleep(10)
    $oBrowser = _IEAttach($randomurl, 'URL')
Until @error<>7

$ie_hwnd=_IEPropertyGet($oBrowser, "hwnd")
ConsoleWrite($ie_hwnd & @CRLF)

The other option is to just run your autoit script as admin with #RequireAdmin at the top if this will work for you.

garbb
  • 679
  • 5
  • 9