Sign in to follow this  
Followers 0
Clark

Is _IEAttach working correctly?

6 posts in this topic

#1 ·  Posted (edited)

Hi all

According to the help file, _IEAttach should exhibit the following:

Success: Returns an object variable pointing to the InternetExplorer Object for all but Embedded and DislogBox modes which return a Window Object Failure: Returns 0 and sets @ERROR

So, to some code:

#include <IE.au3>
$oIE = _IECreate ("http://www.autoitscript.com/forum/index.php")
Send("{TAB 12}")
Send("{ENTER}")
_IELoadWait ($oIE)
$oIE = _IEAttach ("AutoIt")
While $oIE > 0
    $oIE = _IEAttach ("AutoIt")
    sleep(1000)
WEnd
msgbox(0,"Test","wait for it...")

So, the intent of this code is that it should never reach the msgbox line whilst there is an IE window open with AutoIt as a substring in it. However, it always reaches the msgbox line whether the window is there or not.

What am I missing?

The reason I want this is I am writing test automation scripts. I need to have a mechanism to wait for an IE window to close so that my script can continue.

TIA

Clark

Edited by Clark

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Experimenting, I tried changing the while loop to use @error. _IEAttach sets @error to 0 if the window is found and something greater than 0 otherwise:

Some code:

#include <IE.au3>
$oIE = _IECreate ("http://www.autoitscript.com/forum/index.php")
Send("{TAB 12}")
Send("{ENTER}")
_IELoadWait ($oIE)
$oIE = _IEAttach ("AutoIt")
msgbox(0,"Test","Error is " & @error)
While @error = 0
    $oIE = _IEAttach ("AutoIt")
    sleep(1000)
    msgbox(0,"Test","Error is " & @error)
WEnd
msgbox(0,"Test","wait for it...")

No matter if the window is there or not, @error is always zero. I can't figure this out.

Edited by Clark

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ok, well I can't figure out what is going on with _IEAttach, but I can get the effect I am looking for with the following code:

#include <IE.au3>
$oIE = _IECreate ("http://www.autoitscript.com/forum/index.php")
Send("{TAB 12}")
Send("{ENTER}")
_IELoadWait ($oIE)
msgbox(0,"Test","Error is " & @error)
$title=_IEPropertyGet($oIE,"title")
msgbox(0,"Title",$title)
While $title = "General Help and Support - AutoIt Forums"
    sleep(1000)
    $title=_IEPropertyGet($oIE,"title")
    msgbox(0,"Title",$title)
WEnd
msgbox(0,"Test","wait for it...")
Edited by Clark

Share this post


Link to post
Share on other sites

Which version of the IE do you use?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

The correct way to test for an object is

IsObj($oIE)

You're getting confused by the conversions betweens Ints and Object variants in comparisons.

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

#6 ·  Posted (edited)

So, I understand that _IEAttach returns an object variable if it manages to attach to something, but the help file says it should return a 0 (an integer) if it does not get a match. In the example I posted above it does not get a match but clearly does not return 0. In fact it seems to return a random object variable.

Also, I don't really understand how IsObj works in the context of what I am trying to do, which is:

The application pops up a new IE window. I wish to wait until that window closes before continuing my script.

Edited by Clark

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