computergroove Posted April 1, 2012 Share Posted April 1, 2012 $sIEPath = "C:\Program Files\Internet Explorer\Iexplore.exe" If ProcessExists("Iexplore.exe") Then ProcessClose("Iexplore.exe") Sleep(3000) Run($sIEPath) Sleep(5000) Else Run($sIEPath) Sleep(5000) EndIf I remember there being a way to have autoit wait for IE to fully load a page before continuing a script. I dont care if its firefox or ie. What is the function? If it does not load I want to be able to stop my script. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
VixinG Posted April 1, 2012 Share Posted April 1, 2012 (edited) There's _IELoadWait ( http://www.autoitscript.com/autoit3/docs/libfunctions/_IELoadWait.htm ) And also: Try using the IE functions. You can create your own instance of IE, hidden or shown, as well as attach to existing instances of IE. Then just navigate to the page you want to wait for with the IE functions, and put something like _IEPropertyGet($oIE, "busy") in a loop until it is no longer working on loading the page. EDIT: The IE function _IENavigate has a built in option for waiting for the page to load. So you have many options. Here are a few that would work: #include <IE.au3> _IEErrorHandlerRegister() $oIE = _IECreate("about:blank") _IENavigate($oIE, "http://www.autoitscript.com/forum/index.php"); (Default) Wait for page load to complete before returning MsgBox(0, 'Done', 'Done loading page') _IEQuit($oIE) ;OR WITH IE PROPERTY $oIE = _IECreate("about:blank") _IENavigate($oIE, "http://www.autoitscript.com/forum/index.php", 0) ;Return immediately, not waiting for page to load While _IEPropertyGet($oIE, "busy") = True Sleep(50); wait while IE is busy WEnd MsgBox(0, 'Done', 'Done loading page' & @CRLF & "-Open your own instance of IE for the next method.") _IEQuit($oIE) ;OR WITH ATTACH $oIE = _IEAttach('', 'Instance') If @error Then MsgBox(0, 'Error', 'No instance of IE to attach to.') Else _IENavigate($oIE, "http://www.autoitscript.com/forum/index.php") ;Default) Wait for page load to complete before returning MsgBox(0, 'Done', 'Done loading page') _IEQuit($oIE) EndIf Edited April 1, 2012 by VixinG [indent=3][/indent] Link to comment Share on other sites More sharing options...
computergroove Posted April 2, 2012 Author Share Posted April 2, 2012 Here is the new code: $oIE = _IECreate("about:blank") If ProcessExists("Iexplore.exe") Then ProcessClose("Iexplore.exe") Sleep(3000) _IENavigate($oIE, "http://www.google.com", $f_wait = 1); (Default) Wait for page load to complete before returning Sleep(5000) MsgBox(0,"first instance","123") Else _IENavigate($oIE, "http://www.google.com", $f_wait = 1); (Default) Wait for page load to complete before returning ;_IEQuit($oIE) MsgBox(0,"second instance","345") Sleep(5000) EndIf I am getting an error that states I do not have a variable declared. I am sure that it it the $f_wait = 1 variable on the back end of _IENavigate. I have compiled it anyway and the script fails due to an undeclared variable. What am I doing wrong? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
VixinG Posted April 2, 2012 Share Posted April 2, 2012 ??? The problem is, that you are closing the process and there's an error with _IENavigate, because IExplore.exe is closed. #RequireAdmin #include <IE.au3> $oIE = _IECreate("about:blank") If ProcessExists("Iexplore.exe") Then Sleep(3000) _IENavigate($oIE, "http://www.google.com"); (Default) Wait for page load to complete before returning Sleep(5000) MsgBox(0,"first instance","123") Else _IENavigate($oIE, "http://www.google.com"); (Default) Wait for page load to complete before returning ;_IEQuit($oIE) MsgBox(0,"second instance","345") Sleep(5000) EndIf Try this one and tell us if that's what you wanted. [indent=3][/indent] Link to comment Share on other sites More sharing options...
computergroove Posted April 2, 2012 Author Share Posted April 2, 2012 My bad. I was mixing code from the last attempt. Now what I am trying to do is get feedback from _IENavigate and if the page says "page cannot be displayed". Would that fall under @error = 1 General error? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
VixinG Posted April 2, 2012 Share Posted April 2, 2012 (edited) This script works fine on my computer (WinXP pro). Why are you receiving an error? Have you tried this code? Try without "#RequireAdmin" maybe. The code can't be simplier* - check your internet proxy settings, maybe you have messed up something, dunno. 'page cannot be displayed' - strange. Edited April 2, 2012 by VixinG [indent=3][/indent] Link to comment Share on other sites More sharing options...
computergroove Posted April 2, 2012 Author Share Posted April 2, 2012 (edited) I think that $f_wait = 1 is the default and so it is not necessary. I have not gotten that far as of yet because I am trying to put together an @error code within my if statement. Example: $oIE = _IECreate("about:blank") $OutputFile = "error.ini" _IENavigate($oIE, "http://www.google.com"); (Default) Wait for page load to complete before returning If @Error <> 0 Then Local $ProxData = $d & @LF & $e & @LF & $f ;$ProxData is for an error ini file IniWriteSection($OutputFile, $d , $ProxData) ; Writed the data to the ini file in a unique section <----- How do I get the program to start at the beginning again from here?!? ----> EndIf How can I go back to the beginning of my while 1 statement from the above? Edited April 2, 2012 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
VixinG Posted April 2, 2012 Share Posted April 2, 2012 (edited) I don't understand you. 'While 1' creates infinite loop and everything between this and 'WEnd' is going to run infinite times until script ends by function or specific hotkey.Here my knowledge ends, and F1 in SciTE starts Maybe someone other will help you. In the meantime, please read the manual (F1 in SciTE or on http://www.autoitscript.com/autoit3/docs/).Best regards I am not frustrated mate, I am new to AutoIt just like You Edited April 2, 2012 by VixinG [indent=3][/indent] Link to comment Share on other sites More sharing options...
computergroove Posted April 2, 2012 Author Share Posted April 2, 2012 Sorry to frustrate you. Thanks for trying. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html 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