Clark Posted December 13, 2011 Share Posted December 13, 2011 (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 December 13, 2011 by Clark Link to comment Share on other sites More sharing options...
Clark Posted December 13, 2011 Author Share Posted December 13, 2011 (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 December 13, 2011 by Clark Link to comment Share on other sites More sharing options...
Clark Posted December 13, 2011 Author Share Posted December 13, 2011 (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 December 13, 2011 by Clark Link to comment Share on other sites More sharing options...
water Posted December 13, 2011 Share Posted December 13, 2011 Which version of the IE do you use? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
DaleHohm Posted December 13, 2011 Share Posted December 13, 2011 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 Link to comment Share on other sites More sharing options...
Clark Posted December 14, 2011 Author Share Posted December 14, 2011 (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 December 14, 2011 by Clark Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now