Jump to content

Problems using _IE.au3 within While/WEnd


Recommended Posts

Hi!

Currently I'm messing around with _IE.au3 (AutoIt V3.3.6.1).

I'm having some trouble calling '_IELinkClickByIndex()' or '_IELinkClickByText()'.

The first MsgBox appears - the second MsgBox does not.

After calling the two IE functions mentioned above the script stuck somewhere...

But I have no clue where...

Here's the code snippet:

_IENavigate($oIE, "file://" & $sTmp1, 0)
If Not @error Then
    Local $hWnd = _IEPropertyGet($oIE, "HWND")
    If WinExists($hWnd, "") = 1 Then
        WinSetState($hWnd, "", @SW_MAXIMIZE)
        While WinExists($hWnd, "")
            Local $tMsg = TrayGetMsg()
            Switch $tMsg
                Case $hTRAY_I0
                    Local $oFrame = _IEFrameGetObjByName($oIE, "Desktop")
                    If Not @error Then
                        Local $oItem = _IEGetObjById($oFrame, "titleBarLogout")
                        If Not @error Then
                            MsgBox(0, "", "test1")
                            _IELinkClickByIndex($oFrame, 0, 1) ; ... or this: _IELinkClickByText($oFrame, StringStripWS($oItem.innerText, 3), 0, 1)
                            MsgBox(0, "", "test2")
                            _IEQuit($oIE)
                        EndIf
                    EndIf
                    TrayItemSetState($tMsg, $TRAY_UNCHECKED)
                    ExitLoop
                Case $hTRAY_I1
                    _IEQuit($oIE)
                    TrayItemSetState($tMsg, $TRAY_UNCHECKED)
                    ExitLoop
                Case $hTRAY_I2
                    GUISetState(@SW_SHOW, $hGUI)
                    TrayItemSetState($tMsg, $TRAY_UNCHECKED)
                Case $hTRAY_I3
                    GUISetState(@SW_HIDE, $hGUI)
                    TrayItemSetState($tMsg, $TRAY_UNCHECKED)
            EndSwitch
            Sleep(0010)
        WEnd
    EndIf
EndIf

May be there's someone who could help me?

Greets,

-supersonic.

Edited by supersonic
Link to comment
Share on other sites

Set the third parameter to $f_wait = 0 and use a different method to know when the page is finished. Depending on server-side scripts that run continuously and stuff like that, some pages never reach "done" in the way that the function is watching for (...document.readyState = "complete").

;)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Would '_IELoadWait($oIE)' be a solution to my problem?

No, because that's exactly what _IELinkClickByText() does if you have $f_wait = 1. You can crack open the IE.au3 UDF and look at the functions. I recommend it, as it's very instructive. With your script open in SciTE, put the cursor bar on _IELinkClickByText() in your code and then hit CTRL-j. It will open the UDF and jump to the function so you can look at it.

For your issue, you need to find out what else indicates the load is complete besides the status of the .document.readyState property which is what _IELoadWait() uses.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

PsaltyDS,

you are right! ;)

Indeed, '_IELoadWait()' wouldn't help...

In order to solve my issue I use the form count of the target document.

Here's the code:

Local $i = 0
Do
    Local $oForms = _IEFormGetCollection($oIE)
    If Not @error Then
        $i = @extended ; Form count.
    EndIf
    Sleep(10)
Until $i = 1

It works pretty well.

Greets,

-supersonic.

Edited by supersonic
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...