Jump to content

Do not wait for webpage to fully load


 Share

Recommended Posts

Apologies if this has appeared before, but I've searched and cannot find what I'm looking for.

 

In this included example:

#include <IE.au3>


Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetObjByName($oIE, "f")
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)

It waits for http://www.google.com to fully load before the text are input and searched - how to make it so that it inputs the text and searches as soon as that search box and the 'Google Search' button has appeared - rather than waiting for it to fully load?

 
Link to comment
Share on other sites

As soon as it is created you can handle the window but not its content if not loaded

You can try something like this

#include <IE.au3>

Global $g_eventerror = 0 
_IEErrorHandlerRegister("MyErrFunc")

Local $oIE = _IECreate("http://www.google.com", 0, 1, 0)
; msgbox(0,"", _IEPropertyGet($oIE, "hwnd"))

Do
  $g_eventerror = 0
  $input = _IEGetObjByName($oIE, "q")
  ConsoleWrite($g_eventerror & @crlf)
Until $g_eventerror = 0

Local $oForm = _IEFormGetObjByName($oIE, "f")
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)

Func MyErrFunc() 
   $g_eventerror = 1 
Endfunc

This is just an example so be aware to put the right target inside the loop

Edited by mikell
Link to comment
Share on other sites

As soon as it is created you can handle the window but not its content if not loaded

You can try something like this

#include <IE.au3>

Global $g_eventerror = 0 
_IEErrorHandlerRegister("MyErrFunc")

Local $oIE = _IECreate("http://www.google.com", 0, 1, 0)
; msgbox(0,"", _IEPropertyGet($oIE, "hwnd"))

Do
  $g_eventerror = 0
  $input = _IEGetObjByName($oIE, "q")
  ConsoleWrite($g_eventerror & @crlf)
Until $g_eventerror = 0

Local $oForm = _IEFormGetObjByName($oIE, "f")
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)

Func MyErrFunc() 
   $g_eventerror = 1 
Endfunc
This is just an example so be aware to put the right target inside the loop

Well i haven't tested it but even if you can handle the window, in case it responds, you will never be able to fill the fields with data if they are not created.

I don't even know why you posted that example and what it has to do with what the op is asking...

Link to comment
Share on other sites

Well i haven't tested it but even if you can handle the window, in case it responds, you will never be able to fill the fields with data if they are not created.

I don't even know why you posted that example and what it has to do with what the op is asking...

Looks like a valid attempt, to address the OP to me.

Granted, it's probably better used after loadwait, but is certainly relevant to question.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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
 Share

  • Recently Browsing   0 members

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