Jump to content

Problem with _IEQuit, Windows7 and IE8


Recommended Posts

Hello, here's my problem.

One .EXE follows a URL with IE8, collects informations then exits. The IE8's window stays opened to be controlled manually also.

The same .EXE is lunched twice lately to close the IE8's window with "_IEQuit" but I've got one error message n°4 which says : "($_IEStatus_InvalidObjectType) = Invalid Object Type".

In the function "_IEIsObjType" used by "_IEQuit", the value '$s_Name = "HTMLWindow2".

But only "IWebBrowser2", "IWebBrowser" ou "WebBrowser" are allowed when $s_Type="browser".

Everything works fine on Windows XP and IE7.

Where does the problem come from?

Thanks in advance!

Link to comment
Share on other sites

Hi, I've neither used the IE UDF nor do I posess the system needed to investigate the problem your experiencing but pheraps you could just use Send() or WinClose() as a replacement. If your closing a specific Internet Explorer tab and need to use that function then please clarify your requirements.

Spoiler

censored.jpg

 

Link to comment
Share on other sites

Can you please post your script? Preferably the shortest reproducer possible...also, does the _IEQuit example in the helpfile run for you?

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Link to comment
Share on other sites

Thanks a lot for your replies. Well, I have to say that it isn't my resquest and I'm just trying to help someone. We tested plenty codes to see where the problem comes from. The last code which has been tested is this one :

include <IE.au3>
#RequireAdmin
Opt("WinTitleMatchMode",-2)
$Fen_IE = _IEAttach("Google","embedded")
if $Fen_IE=0 Then
   msgbox(0,"","Google non trouvé")
   $Fen_IE = _IECreate("http://www.google.fr",0,1,0)
EndIf

$Fen_IE = _IEAttach("Lycos","embedded")
if $Fen_IE=0 Then
   msgbox(0,"","Lycos non trouvé")
   $Fen_IE = _IECreate("http://www.lycos.fr",0,1,0)
endif
msgbox(0,"","Fin 1er affichage")

$Fen_IE = _IEAttach("Google","embedded")
if $Fen_IE=0 Then  
   msgbox(0,"","Google non trouvé")
   $Fen_IE = _IECreate("http://www.lycos.fr",0,1,0)
else
   _IENavigate($Fen_IE,"http://www.lycos.fr",0)
EndIf

$Fen_IE = _IEAttach("Lycos","embedded")
if $Fen_IE=0 Then  
   msgbox(0,"","Lycos non trouvé")
   $Fen_IE = _IECreate("http://www.google.fr",0,1,0)
Else
   _IENavigate($Fen_IE,"http://www.google.fr",0)
endif
msgbox(0,"","Fin 2ième affichage")

$Fen_IE = _IEAttach("Google","embedded")
if $Fen_IE=0 Then
   msgbox(0,"","Google non trouvé")
else  
   msgbox(0,"","Fermeture Google")
   _IEQuit($Fen_IE)
   MsgBox(0,"",@error)
endif
$Fen_IE = _IEAttach("Lycos")
if $Fen_IE=0 Then
   msgbox(0,"","Lycos non trouvé")
else  
   msgbox(0,"","Fermeture Lycos")
   _IEQuit($Fen_IE)
   MsgBox(0,"",@error)
  
endif

Everything works fine with every Windows and IE7, IE9 but doesn't work* when IE8 is installed.

* : In fact, the problem is when the script is finished, it exits the first IE properly, but can't even close the second one and returns : ($_IEStatus_InvalidObjectType) = Invalid Object Type

Now, I'm waiting for my friend to answer me and then give you some news.

Link to comment
Share on other sites

You're using the same variable name for all of your objects, use different ones for each instance you're creating and see if that affects the outcome.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I have already tried it and still has the same result :

#include <IE.au3>
#RequireAdmin
Opt("WinTitleMatchMode",-2)
$Fen_IE = _IEAttach("Google","embedded")
if $Fen_IE=0 Then
   msgbox(0,"","Google non trouvé")
   $Fen_IE = _IECreate("http://www.google.fr",0,1,0)
EndIf
$Fen_IE2 = _IEAttach("Lycos","embedded")
if $Fen_IE2=0 Then
   msgbox(0,"","Lycos non trouvé")
   $Fen_IE2 = _IECreate("http://www.lycos.fr",0,1,0)
endif
msgbox(0,"","Fin 1er affichage")
$Fen_IE = _IEAttach("Google","embedded")
if $Fen_IE=0 Then
   msgbox(0,"","Google non trouvé")
   $Fen_IE = _IECreate("http://www.lycos.fr",0,1,0)
else
   _IENavigate($Fen_IE,"http://www.lycos.fr",0)
EndIf
$Fen_IE2 = _IEAttach("Lycos","embedded")
if $Fen_IE2=0 Then
   msgbox(0,"","Lycos non trouvé")
   $Fen_IE2 = _IECreate("http://www.google.fr",0,1,0)
Else
   _IENavigate($Fen_IE2,"http://www.google.fr",0)
endif
msgbox(0,"","Fin 2ième affichage")
$Fen_IE = _IEAttach("Google","embedded")
if $Fen_IE=0 Then
   msgbox(0,"","Google non trouvé")
else
   msgbox(0,"","Fermeture Google")
   _IEQuit($Fen_IE)
   MsgBox(0,"",@error)
endif
$Fen_IE2 = _IEAttach("Lycos")
if $Fen_IE2=0 Then
   msgbox(0,"","Lycos non trouvé")
else
   msgbox(0,"","Fermeture Lycos")
   _IEQuit($Fen_IE2)
   MsgBox(0,"",@error)
endif

EDIT : Here's another code tested but same problem, google stays on...

#include <IE.au3>
#RequireAdmin
Opt("WinTitleMatchMode",-2)
$AttachFen_IE = _IEAttach("Google","embedded")
if $AttachFen_IE=0 Then
   msgbox(0,"","Google non trouvé")
   $Fen_IE = _IECreate("http://www.google.fr",0,1,0)
EndIf
$AttachFen_IE2 = _IEAttach("Lycos","embedded")
if $AttachFen_IE2=0 Then
   msgbox(0,"","Lycos non trouvé")
   $Fen_IE2 = _IECreate("http://www.lycos.fr",0,1,0)
endif
msgbox(0,"","Fin 1er affichage")
$AttachFen_IE = _IEAttach("Google","embedded")
if $AttachFen_IE=0 Then
   msgbox(0,"","Google non trouvé")
   $Fen_IE = _IECreate("http://www.lycos.fr",0,1,0)
else
   _IENavigate($Fen_IE,"http://www.lycos.fr",0)
EndIf
$AttachFen_IE2 = _IEAttach("Lycos","embedded")
if $AttachFen_IE2=0 Then
   msgbox(0,"","Lycos non trouvé")
   $Fen_IE2 = _IECreate("http://www.google.fr",0,1,0)
Else
   _IENavigate($Fen_IE2,"http://www.google.fr",0)
endif
msgbox(0,"","Fin 2ième affichage")
$AttachFen_IE = _IEAttach("Google","embedded")
if $AttachFen_IE=0 Then
   msgbox(0,"","Google non trouvé")
else
   msgbox(0,"","Fermeture Google")
   _IEQuit($Fen_IE)
   MsgBox(0,"",@error)
endif
$AttachFen_IE2 = _IEAttach("Lycos")
if $AttachFen_IE2=0 Then
   msgbox(0,"","Lycos non trouvé")
else
   msgbox(0,"","Fermeture Lycos")
   _IEQuit($Fen_IE2)
   MsgBox(0,"",@error)
endif
Edited by blacksoul305
Link to comment
Share on other sites

The problem is with _IEAttach, which seems to behave differently with IE9. Try using the "title" (default) mode and see if that helps.

This worked for me:

#include <IE.au3>
#RequireAdmin

Opt("WinTitleMatchMode", -2)

$Google_IE = _IEAttach("Google")
If $Google_IE = 0 Then
    MsgBox(0, "", "Google non trouvé")
    $Google_IE = _IECreate("http://www.google.fr")
EndIf

$Lycos_IE = _IEAttach("Lycos")
If $Lycos_IE = 0 Then
    MsgBox(0, "", "Lycos non trouvé")
    $Lycos_IE = _IECreate("http://www.lycos.fr")
EndIf
MsgBox(0, "", "Fin 1er affichage")

_IENavigate($Google_IE, "http://www.lycos.fr")

_IENavigate($Lycos_IE, "http://www.google.fr")

$Google_IE_Attached = _IEAttach("Google")
If $Google_IE_Attached = 0 Then
    MsgBox(0, "", "Google non trouvé")
Else
    MsgBox(0, "", "Fermeture Google")
    _IEQuit($Google_IE_Attached)
    MsgBox(0, "", @error)
EndIf

$Lycos_IE_Attached = _IEAttach("Lycos")
If $Lycos_IE_Attached = 0 Then
    MsgBox(0, "", "Lycos non trouvé")
Else
    MsgBox(0, "", "Fermeture Lycos")
    _IEQuit($Lycos_IE_Attached)
    MsgBox(0, "", @error)
EndIf
Link to comment
Share on other sites

Hum, GMK, I think that you have the answer. Tried your code and it worked perfectly fine. I gave the answer to my mate and I'll keep you informed.

Thanks for your replies!

EDIT : Okay, here's my mate's answer :

Sorry my late answer, I didn't have time to answer this week-end, moreover, I can test all the codes only at work, i don't have the required configuration to do at home.

The code doesn't work, I've got also a problem with _IEAttach function. That function works properly only if I add "embedded" parameter.The following parameters : "title", "windowtitle" and "url" do not work systematically.

They seem work only on the fisrt window, like _IEQuit although, in the exemple this is the google's windows changed to "Lycos" which works normally.

In the GMK's code, here's the guilty part :

$Google_IE_Attached = _IEAttach("Google")
If $Google_IE_Attached = 0 Then
MsgBox(0, "", @error) ;~ <- return @error=7 ($_IEStatus_NoMatch) = No Match
MsgBox(0, "", "Google non trouvé")
Else
MsgBox(0, "", "Fermeture Google")
_IEQuit($Google_IE_Attached)
MsgBox(0, "", @error)
EndIf

I think that my problems with _IEAttach and _IEQuit are linked but, whereby?

Thanks a lot for your replies!

Does anyone see where does the problem come from?

Thanks in advance!

Edited by blacksoul305
Link to comment
Share on other sites

I haven't read through the full post, but this is the wrong way to check to see if _IEAttach was successful:

If $Google_IE_Attached = 0 Then

Instead, use:

If Not IsObj($Google_IE_Attached) Then

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

Okay, thank you for your reply, I'll keep you informed!

EDIT : My friend answered, here is what he said :

Hello,

it's not getting better, to have _IEAttach working "properly", I must use "embedded" parameter otherwise opened windows won't be systematically found.

Nonetheless, I will modify my code to apply the Dale's remark.

Thanks.

Thanks a lot for your help.

Edited by blacksoul305
Link to comment
Share on other sites

The return object type for attaching to an embedded IE window is different than attaching to a non-embedded window. The return type for an embedded window is "HTMLWindow2", and if you look at the workings of the function _IEQuit, that doesn't match what _IEQuit can work with.

$Google_IE_Attached = _IEAttach("Google", "embedded")
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & 'String(ObjName($Google_IE_Attached))' & @lf & @lf & 'Return:' & @lf & String(ObjName($Google_IE_Attached))) ;### Debug MSGBOX

Modified the code in post #7 to use the embedded option, and you'll see in the msgbox what it returns. _IEQuit on the other hand requires that to read as one of the following.

If ($s_Name = "IWebBrowser2") Or ($s_Name = "IWebBrowser") Or ($s_Name = "WebBrowser") Then $objectOK = True

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Thanks a lot for your help, I'm gonna send him your message.

EDIT : Here's my mate answer :

By modifying the proposed code, the returned value is "HTMLWindows2" which is good.

My problem looks more linked to _IEAttach than _IEQuit.

So this is my question : why does not _IEAttach work systematically with "title", "windowtitle" or "URL" ?

I have modified the BrewManNH and deleted the embedded paramater.

$Google_IE_Attached = _IEAttach("Google")
MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & 'String(ObjName($Google_IE_Attached))' & @lf & @lf & 'Return:' & @lf & String(ObjName($Google_IE_Attached))) ;### Debug MSGBOX

In that case, the returned value is blank, which explains that _IEAttach doesn't work.

Thanks for your help ! Edited by blacksoul305
Link to comment
Share on other sites

"embedded" in required for webbrowser controls enbedded into application windows and for HTAs (hypertext applications).

Also, I see no mention anywhere of the AutoIt version being used. Make certain you are using the most recent released or beta version as changes were made in AutoIt and IE.au3 related to object name/type.

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

This second hand problem reporting makes this a pretty inefficient interaction and makes trying to help pretty frustrating.

For most of the _IEAttach modes, IE.au3 loops through the "Shell.Application" collection, looking for an object that matches the criteria you specify. It first checks each object to see if it has .Type and a .document.title property (to weed out Windows Explorer and other windows, like Outlook Today) - it returns NoMatch if nothing matches your criteria.

Embedded and DialogBox modes work differently. They examine the window that matches the Title or HWND you supply and looks for embedded WebBrowser controls.

This is not compiled code - you can easily open IE.au3 and see what it is doing and do some of your own diagnostics.

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,

I guess that it must be a little bit disturbing to help someone who gives information to another one. In fact, I posted the topic for someone else who doesn't speak in English. The topic didn't have one answer in the fourteen following days. I tried to help him by doing some research or codes but it didn't help a lot. Now, I'm translating your answer (as better as I can), post them in the other topic and then wait for an answer to translate to you.

If some of you have knowledge in french, you can go there to see what were our first codes and how we are progressing.

Thank you a lot all for your replies, codes and explanations. We will work on your ideas.

EDIT : My friend works a lot on your ideas and he starts to have more accurate questions. Here's his research through the IE.au3 file.

Hello,

I progressed faster than I thought

The modification in the _IEAttach method in IE.au3 after the 388 line

"Local $f_NotifyStatus, $status, $f_isBrowser, $s_tmp"

Insertion of the following lines:

Local $string = ""
For $o_window In $o_ShellWindows   
    $string = $string & $o_window.Locationurl & @CRLF  
next
MsgBox(0, "Shell Windows", "You have the following shell windows:" & @CRLF & @CRLF & $string)[/background][/color][/font][/size]
[color=#323D4F][font=arial, helvetica, sans-serif][size=3][background=rgb(236, 236, 236)]

Saved as IE2.au3.

New test code :

First test

All IE windows are closed

#include <IE2.au3>[/background][/size][/font][/color]
[color=#323D4F][font=arial, helvetica, sans-serif][size=3][background=rgb(236, 236, 236)]Opt("WinTitleMatchMode",-2)[/background][/size][/font][/color]
[color=#323D4F][font=arial, helvetica, sans-serif][size=3][background=rgb(236, 236, 236)]#RequireAdmin[/background][/size][/font][/color]
[color=#323D4F][font=arial, helvetica, sans-serif][size=3][background=rgb(236, 236, 236)]$Google_IE_Attached = _IEAttach("Google","url")     ;~ msgbox -> Blank
If Not IsObj($Google_IE_Attached) Then
   $Google_IE_Attached = _IECreate("http://www.google.fr",0,1,0)
EndIf 
 
$Lycos_IE_Attached = _IEAttach("Lycos","url")      ;~ msgbox -> http://www.google.fr
if $Lycos_IE_Attached=0 Then
   $Lycos_IE_Attached = _IECreate("http://www.lycos.fr",0,1,0)
endif[/background][/size][/font][/color]

[color=#323D4F][font=arial, helvetica, sans-serif][size=3][background=rgb(236, 236, 236)]$Fen_IE=_IEAttach("Google","url")                 ;~ msgbox -> http://www.google.fr[/background][/size][/font][/color]
[color=#323D4F][font=arial, helvetica, sans-serif][size=3][background=rgb(236, 236, 236)]

Second test

"GOOGLE" and "LYCOS" windows are opened "manually" before the lunching of the programm.

#include <IE2.au3>[/font][/size]
[size=3][font=arial, helvetica, sans-serif]Opt("WinTitleMatchMode",-2)[/font][/size]
[size=3][font=arial, helvetica, sans-serif]#RequireAdmin[/font][/size]
[size=3][font=arial, helvetica, sans-serif]$Google_IE_Attached = _IEAttach("Google","url")   ;~ msgbox -> http://www.google.fr
                                                    ;~         http://www.lycos.fr
If Not IsObj($Google_IE_Attached) Then
   $Google_IE_Attached = _IECreate("http://www.google.fr",0,1,0)
EndIf 
 
$Lycos_IE_Attached = _IEAttach("Lycos","url")      ;~ msgbox -> http://www.google.fr
                                                    ;~         http://www.lycos.fr
if $Lycos_IE_Attached=0 Then
   $Lycos_IE_Attached = _IECreate("http://www.lycos.fr",0,1,0)
endif[/font][/size]
[size=3][font=arial, helvetica, sans-serif]$Fen_IE=_IEAttach("Google","url")                    ;~ msgbox -> http://www.google.fr
                                                     ;~        http://www.lycos.fr[/font][/size]
[font=arial, helvetica, sans-serif][size=3]

Third test

Only the "GOOGLE" windows is opened "manually" before the luncking of the programm.

#include <IE2.au3>[/size][/font]
[font=arial, helvetica, sans-serif][size=3]Opt("WinTitleMatchMode",-2)[/size][/font]
[font=arial, helvetica, sans-serif][size=3]#RequireAdmin[/size][/font]
[font=arial, helvetica, sans-serif][size=3]$Google_IE_Attached = _IEAttach("Google","url")   ;~ msgbox -> http://www.google.fr
If Not IsObj($Google_IE_Attached) Then
   $Google_IE_Attached = _IECreate("http://www.google.fr",0,1,0)
EndIf 
 
$Lycos_IE_Attached = _IEAttach("Lycos","url")      ;~ msgbox -> http://www.google.fr
if $Lycos_IE_Attached=0 Then
   $Lycos_IE_Attached = _IECreate("http://www.lycos.fr",0,1,0)
endif[/size][/font]

[font=arial, helvetica, sans-serif][size=3]$Fen_IE=_IEAttach("Google","url")                   ;~ msgbox -> http://www.google.fr
                                                    ;~         http://www.lycos.fr[/size][/font]
[font=arial, helvetica, sans-serif][size=3]

Only the first window opened by the programm is reocgnized by "ObjCreate("Shell.Application")" of the _IEAttach method.

I've tested on several PC :

Works on XP + IE8

Doesn't work on Vista + IE8, W7 + IE8, W7 + IE9.

Is the problem coming from the _IECreate method, the system's configuration or IE?

My friend said also about the reporting problem :

I am so sorry to do not participate directly on the forum but I think my english is understandable.About the answers, the automatic translators are not perfect, so I don't understand everything.

And for my part, I'm studying english at school, love that language but it still hard to understand and to write correctly everything. By the way, this is a good way of practise, hope that I am enough understable for you.

From us, thank you a lot for your help!

Edited by blacksoul305
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...