Sign in to follow this  
Followers 0
magicknite

_IEAttach and Vista

18 posts in this topic

I've searched the forum and know this subject has been touched a few times; but, I still haven't seen a definitive answer/solution.

I have a point where if the user has closed the original _IECreate window it attempts to _IEAttach to an already open window to the same website (if there is one) using the URL option.

The script with the _IEAttach function works fine on different XP machines running IE6 and IE7. But it fails on a VISTA machine running IE7 returning the error below (no com errors noted).

--> IE.au3 V2.3-1 Warning from function _IEAttach, $_IEStatus_NoMatch

I am running the script with #RequireAdmin and everything else works identically fine, just this failure to attach is a mystery.

Is there an answer why (not) and/or a solution? Dale?

thanks in advance

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Examine what browsers are being seen to see if it gives you clues (this is an adaptation of an example in the helpfile):

$i = 1
While 1
    $oIE = _IEAttach ("", "instance", $i)
    If @error = $_IEStatus_NoMatch Then ExitLoop
    ConsoleWrite("Url: [" & _IEPropertyGet($oIE, "locationurl") & "]" & @CRLF)
    $i += 1
WEnd

Dale

Edit: Oops, simplified example too much... fixing

Edit2: initial value of $i should have been 1 instead of 0

Edited by DaleHohm

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

Dale,

Thanks for the help. I did as you suggested. I opened a window via my script and closed the script making the window a 'script orphan' set to and logged into the secured website (noted that protected mode is off). I then opened a separate IE window from the desktop, set to Google (noted that protected mode is on).

My script starts with $oIE = 0, I then ran my script generating a new window ($oIE <>0) and then close that new window. If I hit a button to navigate to a new place, the script will not find the original window and then go search for any other window open to this site and attach and navigate.

It appears that IE doesn't recognize the "orphan" window, additionally @extended = 1 after the attach attempt.

--> IE.au3 V2.4-0 Error from function _IEAttach, $_IEStatus_InvalidValue ($i_instance < 1)

--> IE.au3 V2.4-0 Error from function _IEPropertyGet, $_IEStatus_InvalidDataType

Url: [0]

Url: [http://www.google.com/]

--> IE.au3 V2.4-0 Warning from function _IEAttach, $_IEStatus_NoMatch

When I run the same script on an XP machine with IE6, it recognizes the "other" window and attaches and @extended = 0 after the attach attempt.

I am truly baffled by the difference. Any ideas?

Share this post


Link to post
Share on other sites

Sorry, my bad. I bungled my example script... initial value of $i needs to be 1 instead of 0.

Please try again.

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 1 vs 0 was no big deal. muttley The result is still the same as described earlier, albeit much cleaner. :)

In Vista, the script 'orphaned' window is not recognized, while the independently opened [google] window is seen.

In XP both windows are seen and the IEAttach proceeds as expected.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I'm not following your description completely, but I'm suspicious that Vista is setting up two security contexts and is not allowing you to span them. Perhaps one running as Admin and the other not or one in protected mode and one not.

IE.au3 suppresses COM errors when it believes they are expected. One of these places is when walking the Shell.Windows collection to find browsers with _IEAttach. Please try adding this to your code and report the console results:

$__IEAU3Debug = True

Dale

p.s. I don't have ready access to a Vista machine for testing as I recently blew away my Vista VM

Edit: typos

Edited by DaleHohm

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

Yes, it has to be one or the other, because my script cannot "see" the IE window created by the script but can "see" an independently created window.

My problem is how to figure out which one it is and if there is a possible work-around.

Sorry to hear about your Vista VM, perhaps someone else can run the code and make sure it is a vista problem and not my imagination or my machine.

As mentioned earlier, the premise is that if the user has initially logged into a secure website ($oIE <>0). A new window will be generated if later the user has either closed the initially generated window or changed the URL to one other than the secure website. Otherwise the plan is to attach to the existing or another secure website window and proceed.

Problem: IEAttach isn't working on a VISTA machine.

Independently generated IE windows show Protected Mode: ON, while the autoit generated window shows Protected Mode: Off

Again, thanks for taking the time to help. It is utterly baffling to me, a relative IE innards novice.

Excuse the crude example code.

#RequireAdmin
#include <GUIConstantsEX.au3>
#include <IE.au3>

Global $main, $ILog1
$oIE = 0
Opt("WinTitleMatchMode", 2)
;
HotKeySet("{ESC}", "Terminate")
Func Terminate()
    Exit 0
EndFunc   
;
While 1;master procedure loop
    Main()
    GUIDelete($main)
WEnd
;
Func Main() 
$main = GUICreate("Attach Test") 
$Button_1 = GUICtrlCreateButton ("AutoIt Window",  20, 30, 100)
$Button_2 = GUICtrlCreateButton ("Goggle Window",  20, 80, 100)
GUISetState ()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button_1
                $ILog1 = "http://autoitscript.com"
                ILogOn()
                ExitLoop
        Case $msg = $Button_2
                $ILog1 = "http://google.com"
                ILogOn()
                ExitLoop
    EndSelect
WEnd
EndFunc
;       
Func ILogon()
Select
    Case $oIE = 0 Or (Not (WinExists("Google") Or WinExists("AutoIt")))
        $oIE = _IECreate("about:blank", 0, 1, 0)
        _IELoadWait($oIE, 500)
        WinActivate("Internet Explorer")
        Sleep(500)
        WinSetState("lank", "", @SW_MAXIMIZE)
        _IENavigate($oIE, $ILog1, 0)
        _IELoadWait($oIE, 500)
    Case Else
        $oIE = _IEAttach("google.com", "URL")
        _IENavigate($oIE, $ILog1, 0)
        _IELoadWait($oIE, 1000)
        MouseMove(0, 0, 0)
    EndSelect
    Sleep(500)
EndFunc

Share this post


Link to post
Share on other sites

So did you do the test with $__IEAU3Debug = True ???

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

Sorry for the delayed response. I tried a run with $__IEAU3Debug = True, but didn't get any results (don't really understand the function, sorry).

Since the IECreated window can't seem to be seen, I did some basic checking and it seems that, in VISTA, the HWND from IECreate is a null string (at least for me). So there is definitely some kind of User Interface Privilege Isolation (UIPI) action going on.

Since the IEAttach isn't critical to my script, I just devised a @OS workaround for VISTA. Log this as just one more strange VISTA induced anomaly.

Share this post


Link to post
Share on other sites

Sorry to re-open an old thread, but I am facing this same issue on Vista and Windows 2008. (at least you can tell I searched for resolution before posting!)

Anyway, using the following code on XP works as expected, but on Vista and 2008 it cannot find and attach to any browsers. Has anyone found a solution to this yet?

Thanks!

Dim $aIE[1]
$aIE[0] = 0

$i = 1
While 1
    $oIETemp = _IEAttach ("", "instance", $i)
    If @error = $_IEStatus_NoMatch Then ExitLoop
        ReDim $aIE[$i + 1]
        $aIE[$i] = $oIETemp
        $aIE[0] = $i
        $i += 1
WEnd

For $i = 1 To UBound($aIE) - 1
    _log("Found Browser: " & _IEPropertyGet ($aIE[$i], "title"))
Next

Share this post


Link to post
Share on other sites

I have no problem with this code on Vista.

You'll need to isolate and explain your problem much better.

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

With that code snippet I sent on XP works fine. I.e. the Log function (which is just a function to write to a text file) will list each open browser by title to the log text file. On 2008 nothing is ever listed to the text file. The $aIE array remains empty. So no matter the number of open browsers on 2008 I can (with this code) not attach to any open browsers and check their titles then, based on the matching title name I specify, return a handle to the open browser I want.

Again, this works 100% on XP and 0% on 2008.

Did you modify that code snippet at all (excepting the _Log function) for it to work for you?

Thanks,

Ciege...

Share this post


Link to post
Share on other sites

#include <IE.au3>
Dim $aIE[1]
$aIE[0] = 0

$i = 1
While 1
    $oIETemp = _IEAttach ("", "instance", $i)
    If @error = $_IEStatus_NoMatch Then ExitLoop
        ReDim $aIE[$i + 1]
        $aIE[$i] = $oIETemp
        $aIE[0] = $i
        $i += 1
WEnd

For $i = 1 To UBound($aIE) - 1
    ConsoleWrite("Found Browser: " & _IEPropertyGet ($aIE[$i], "title") & @CR)
Next

You may need to turn off UAC, although I don't believe I had it turned off when I tested.

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

OK, I think I found the root cause.

If I have #RequireAdmin in my script (to work around the issue of _IECreate creating two browsers on Vista) then _IEAttach will find 0 browsers to attach to. When I remove #RequireAdmin then two browsers are created, but I can use _IEAttach to find them.

Try this attached code once with #RequieAdmin enabled and once with it disabled to see what I mean. You may also have to remove the _IELoadWait ($oIE) command when #RequireAdmin is removed because the initial blank browser that is created never completes loading.

#include <IE.au3>
#RequireAdmin 


Local $strTitle
Local $optCheckAddressBarVisible = FALSE

Local $oIETemp
Local $AddressVisibleState

$oIE =_IECreate("www.yahoo.com", 0, 1, 0, 1)
_IELoadWait ($oIE)

    Dim $aIE[1]
    $aIE[0] = 0

    $i = 1
    While 1
        $oIETemp = _IEAttach ("", "instance", $i)
        If @error = $_IEStatus_NoMatch Then ExitLoop
        ReDim $aIE[$i + 1]
        $aIE[$i] = $oIETemp
        $aIE[0] = $i
        $i += 1
    WEnd

    MsgBox(0, "", "Found # of Browsers: " & UBound($aIE) - 1)

    For $i = 1 To UBound($aIE) - 1
        MsgBox(0, "", "Found Browser: " & _IEPropertyGet ($aIE[$i], "title"))
        _IELoadWait ($aIE[$i])
        If StringUpper($strTitle) = StringUpper(_IEPropertyGet ($aIE[$i], "title")) Then
            If $optCheckAddressBarVisible = TRUE Then
                $AddressVisibleState = _IEPropertyGet ($aIE[$i], "addressbar")
                If StringInStr(_IEPropertyGet ($aIE[$i], "innertext"), "Verifying installation...", 0) Then
                ;If this is the Verifying Installation Window, skip it...
                Else
                    If $AddressVisibleState = FALSE Then
                    EndIf
                EndIf
            Else
            EndIf
        EndIf
    Next

Share this post


Link to post
Share on other sites

I recently experienced this myself as I reluctantly upgraded to Vista. Turning off UAC will solve it (I was pissed at UAC before I started, so I had no trouble deciding to turn it off). It is complicated now however. Please try some of the other recommendations in the helpfile like turning off protected mode or adding the site to the trusted list (trusted sites have protected mode tured off).

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

Yeah, I had to disable UAC. I needed #RequireAdmin to make registry changes but that caused the IE issues. So, off goes UAC.

After doing some research it seems that when IE is launched with elevated authority the thread that it runs on cannot be communicated with from the ShellWindows thread. There is a way to make it work using a BHO (browser Helper Object) but that was too much work for now since I can bypass it with UAC disabled.

Thanks for the help!

Ciege...

Share this post


Link to post
Share on other sites

Sounds like you may have found some good discussion of this issue... can you share pointers?

thanks,

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'm afraid I didn't save the links. Once I got to the (frustrated) point of realizing I just needed to disable UAC I closed all my google searches on the subject. Sorry.

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