sumit Posted July 16, 2007 Share Posted July 16, 2007 I load a page in internet Explorer. Sometimes it doesnt load , now I want to detect when this has happened. I tried to use if winexists("Cannot find server") but this doesnt always work because sometimes title fo the IE window is "No page to Display" sometimes "Error" it always changes on different computers. So please help me . Code would be appreciated. Link to comment Share on other sites More sharing options...
someone Posted July 16, 2007 Share Posted July 16, 2007 Check out _IELoadWait(). It will allow you to check if a page is loaded. Other then that, since the timeout error can change on different computers, you can test an element on the page to see if it exists. For instance do an _IEFormElementGetObjByName() on a known form element and if it errors its more then likely because the page hasn't loaded yet. While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
sumit Posted July 16, 2007 Author Share Posted July 16, 2007 (edited) Check out _IELoadWait(). It will allow you to check if a page is loaded. Other then that, since the timeout error can change on different computers, you can test an element on the page to see if it exists. For instance do an _IEFormElementGetObjByName() on a known form element and if it errors its more then likely because the page hasn't loaded yet. Here is my code. $oIE = _IECreate ("http://mptadsl.net.mm/WGarden/Popup.php", 0, 0, 1, 0) _IELoadWait($oIE) If WinExists("Cannot") Then _IEQuit($oIE) $var = Ping("172.24.0.3",1000) If $var Then MsgBox(48, "Unable to Connect to Server", "Please Check the Proxy Settings in Internet Explorer") Exit Now what i mean is how do i detect that after loading a blank page has come . i think i cant use _IEFormElementGetObjByName() for a blank page. Please suggest . code would be appreciated. Thanks Edited July 16, 2007 by sumit Link to comment Share on other sites More sharing options...
sumit Posted July 16, 2007 Author Share Posted July 16, 2007 Cmmon guys there's got a be a way. Its really important for me. Link to comment Share on other sites More sharing options...
Siao Posted July 16, 2007 Share Posted July 16, 2007 If you're using _IELoadWait function, might as well check it's return, no? "be smart, drink your wine" Link to comment Share on other sites More sharing options...
GMK Posted July 16, 2007 Share Posted July 16, 2007 Here's one possible way:#include <IE.au3> $oIE = _IECreate("http://mptadsl.net.mm/WGarden/Popup.php", 0, 0, 1, 0) $sHTML = _IEBodyReadHTML($oIE) If StringInStr($sHTML, "cannot") Then _IEQuit($oIE) Ping("172.24.0.3", 1000) If @error Then MsgBox(48, "Unable to Connect to Server", "Please Check the Proxy Settings in Internet Explorer") Exit EndIf EndIf Link to comment Share on other sites More sharing options...
someone Posted July 16, 2007 Share Posted July 16, 2007 Few things to try/make not of...In using IELoadWait, put a delay such as _IELoadWait ($oIE, 100). What does the loaded page have in it? Check for one element the loaded page should have, and if that element doesn't exsist it more then likely means the page isn't loaded. I've done that in some of my scripts and it works well. Also read up on the documentation in IELoadWait, there are reasons why the code won't work in all cases, most of which I don't understand by Dale gives a few suggestions for when IELoadWait can't be used.Hopefully this helps... While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
DaleHohm Posted July 16, 2007 Share Posted July 16, 2007 Here's one possible way:#include <IE.au3> $oIE = _IECreate("http://mptadsl.net.mm/WGarden/Popup.php", 0, 0, 1, 0) $sHTML = _IEBodyReadHTML($oIE) If StringInStr($sHTML, "cannot") Then _IEQuit($oIE) Ping("172.24.0.3", 1000) If @error Then MsgBox(48, "Unable to Connect to Server", "Please Check the Proxy Settings in Internet Explorer") Exit EndIf EndIfThis is the approach I would suggest. Regarding the _IELoadWait not always working... it will do what it is supposed to do, but not always what you want it to do. If there is a client-side redirect of a page for example, _IELoadWait returns when the initial page load is done, but has no way to know that a new page is immediately being navigated to. Also, the return values of _IELoadWait are likely not going to help you much, because loading a good page or an error page are all the same to it. There are also ways to get the server response code (the 404 error for example), but it is harder to implement, so try this method first. 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...
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