Jump to content

_IEAttach does not always work:Doesn't work when Shell isn't launched


Yusuke
 Share

Recommended Posts

Hi,

I am using AutoIT to build a script launching an installation console running before the Shell (explorer.exe) has started (GUIRunOnce)...

My main script creates an Embedded IE Window inside its own GUI to use as a console.

Other scripts are launched from this main script and they reuse the IE Console created to print their own messages on it, using _IEAttach.

While this work fine when the Shell (Explorer.exe) is running, it doesn't work when the Shell isn't running (I assume it also applies if the user uses alternative shells than explorer.exe like BlackBox or AstonShell).

My IE Console is created but the child scripts can't attach to it.

The error is get is :

Line -1

Error: The requested action with this object has failed.

Actually, after some debugging, it looks like that _IEAttach has a problem on this line.

Local $o_ShellWindows = $o_Shell.Windows (); collection of all ShellWindows (IE and File Explorer)

I think that the o_Shell.Windows() method ( http://msdn2.microsoft.com/en-us/library/bb774107.aspx ) fails because the Shell is not running and hence the method can't find the windows that are children to the Shell.

The collection is then reused in a loop that is crucial for the _IEAttach to run successfully.

I think the solution is to use something else than Shell.Windows(), but I am not sure which... FindWindow API perhaps ?

Is there a way for you to fix this function ?

Reproduce Code attached.

Reproduce Steps

1°) Open Archive in WinZip/WinRAR, etc...

2°) Kill all instances of Explorer.exe so it doesn't run anymore

3°) Launch Main.au3

4°) Launch Child.au3

Thanks in advance.

--

Versions :

AutoIt : 3.2.8.1 (fails with latest beta as well)

IE.au3

Version: V2.3-1

Last Update: 8/13/07

Script used on WinXP SP2 (bug also happens on Windows Server 2003)

Reproduce.zip

Edited by Yusuke
Link to comment
Share on other sites

I do not consider this to be a bug.

Thanks for taking thte time to document it with a reproducer however. Please note that the posting guidelines for bug reports ask that you first post them to the General Support forum first to have them vetted (see sticky post).

I am really not interested in creating a generalized solution in IE.au3 for a situation like this. Many of the _IEAttach modes rely in the Shell object window collection, as you noted, and therefore explorer.exe is a requirement.

As you studied the code, you will also have noticed that the "embedded" option of _IEAttach does NOT rely on the Shell object. It instead uses a specific window title or window handle (hwnd) and allows you to attach to the browser control contained. Even without explorer.exe running you should be able to supply a window title or hwnd to _IEAttach embedded and get what you need.

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

Link to comment
Share on other sites

Hi,

Thanks for your answer.

I do not consider this to be a bug.

It doesn't seem to be behave as you say it is and as it is currently documented, though... which corresponds to my definition of a bug. ;-)

As you studied the code, you will also have noticed that the "embedded" option of _IEAttach does NOT rely on the Shell object. It instead uses a specific window title or window handle (hwnd) and allows you to attach to the browser control contained. Even without explorer.exe running you should be able to supply a window title or hwnd to _IEAttach embedded and get what you need.

From Child.Au3 from the reproducer.

#include <IE.au3>
Global $objIE = _IEAttach("Main Script", "embedded")
MsgBox(64, "Message", "After _IEAttach")
_IEBodyWriteHTML($objIE, "I am the Child Script !")

Unless I am missing something, isn't it what I am doing already ?

you will also have noticed that the "embedded" option of _IEAttach does NOT rely on the Shell object

Actually, it does, even if it doesn't use explicitely the result in this case, it still chokes when the function is called...

Func _IEAttach($s_string, $s_mode = "Title")
    $s_mode = StringLower($s_mode)
    Local $o_Shell = ObjCreate("Shell.Application")
    Local $o_ShellWindows = $o_Shell.Windows(); collection of all ShellWindows (IE and File Explorer)

It crashes on the line below and doesn't execute code any further because of the error occuring at that line:

Local $o_ShellWindows = $o_Shell.Windows(); collection of all ShellWindows (IE and File Explorer)

As the Windows' collection isn't used when attaching to embedded IEs, then may I suggest you move the faulty line only before the For loop so it doesn't crash anymore for people using the embedded mode in this context.

I did on my local file and it works fine, but it would be great if you could amend this so it stays that way in the next AutoIt releases and for people wanting to use it in the same context as me.

Many of the _IEAttach modes rely in the Shell object window collection, as you noted, and therefore explorer.exe is a requirement.

May I suggest you amend the documentation page of the _IEAttach function to include this ?

I am really not interested in creating a generalized solution in IE.au3 for a situation like this.

I agree that the GUIRunOnce situation is rare (but is frequent enough when you do unattended software deployments, which is what AutoIT was created for originally), but there are a lot of people around here that run with alternative shells.

People creating AutoIT script using this feature would probably like it to behave fine in whatever shell is being used as it may result in strange bugs.

You're the one to decide, but please think over it again : it doesn't happen in just a rare case.

At any rate, if you only support explorer.exe as the Shell and require it running for some cases where the function is running, please state it in the documentation so it avoid confusion and misuses of this function.

Thanks a lot.

Link to comment
Share on other sites

Ah, point taken. Thanks for the additional information and analysis.

Yes, this can be improved.

I'll examine more closely.

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

Link to comment
Share on other sites

Testing verified that simply moving the two lines

Local $o_Shell = ObjCreate("Shell.Application")
    Local $o_ShellWindows = $o_Shell.Windows (); collection of all ShellWindows (IE and File Explorer)

down 20 lines so that they appear after the Embedded and DislogBox code and just before the For loop that iterates the ShellWindow collection allows your test code to work.

Thanks for the report. I'll prepare this and a documentation tweak for release.

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

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