Jump to content

how to wait for _ieQuit($oIE) to finish

Go to solution Solved by jdelaney,

Recommended Posts

I'm sure this is question easy, but I am new to Autoit so I can't figure it out.

My main loop has a very complicated internet explorer script that is causing me a lot of problems. (Please, don't ask me for details about that complicated code, it is irrelevant to this question, and is hard to explain.)

I got my complicated code to work by closing the previous internet process at the beginning of the loop.

But, I discovered that _ieQuit runs asynchronously, so I had to put in a sleep(5000)  [sleep(2000) was NOT long enough -- things still went wrong!!!].

The script runs fine, but it is very slow .

So, I want to know how to wait for the _ieQuit to finish.

Something like this

set $oIE = _IeCreate

while $moreToDo


   while $oIE.readystate  <> 4 ;  <<== this is how I do it in vba, but it didn't work in Autoit. It said $oie was not an object



   if processexists("iexplorer.exe") then   ; 

       exit 9999 ; error condition which should never happen.


    set $oIE = _ieCreate

,,,, complicated code


Edited by Coded4Decades
Link to comment
Share on other sites

As far as I'm aware, your script will not continue until after _IEQuit has returned, and calling the .quit method on IE is almost instantaneous, but if you need to be super sure, you could always slap a while loop after it check for the process...

While ProcessExists ("iexplorer.exe") <>  0 
Edited by Prime03
Link to comment
Share on other sites

  • Solution

Make sure you wait for your process to close, and not just any IE...else, you might never exit the loop...unless you are absolutely certain there will only be one IE during execution.

#include <WinAPI.au3>
$hIE = _IEPropertyGet($oIE,"hwnd")
$iPID = ""

While ProcessExists ($iPID) <>  0 
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Regarding <<IEQuit is super>> 

Well, during last week's testing it looked like I needed the sleep(3000).   But today, I discovered it was becaise my IE was Visible.  If I left IE invisible, the IEQuit was much faster.

But, to be on the safe side, I posted this question. Both of your responses work for me.

The addition of the Hwnd lookup is a nice touch which makes the code slightly safer, so that is the version I am using.

Thanks for your help.

Edited by Coded4Decades
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...