Jump to content

How to get innertext of IE tab


Xema
 Share

Recommended Posts

Hi guys,

Here is the context of my problem: I have an IE window that opens several tabs (in fact, a lot, around 50). I am navigating through the tabs (with ControlSend "^i") and wish to get the innertext of the current displayed tab. However what comes from the _IEPropertyGet($global_ie, "innertext") command is every time the innertext of the first tab (the one the IE has been created with).

My question is: how to get the focus of the current tab?

Some constraints I have:

  • I cannot doing graphical things since the IE window is going to be hidden
  • I cannot refresh/reload the tabs/pages (with 50 tabs, it ends up with too much requests and being caught by the anti-DDOS bot of the website)
  • I cannot open the tabs in different IE (too many tabs, not sure my PC can handle 50 IEs at once)

Additional informations:

  • Tabs are created using the Navigate2 function (with the parameter "0x1000")
  • I navigate through the tabs using the function ControlSend( ... , "^$i)

I am quite new using Autoit (and any automation tools), so it is possible I didn't understand some fundamentals things.

Thanks a lot guys!

Xema

Link to comment
Share on other sites

Can you provide some details on the site (ie: URL) and why you need 50 tabs?

FWIW, I have used the following to retrieve the active tab in IE --

Func _IEGetActiveTab()
Local $hwnd, $i, $title, $oIE

    ; get first IE instance
    $oIE = _IEAttach ("", "instance", 1)

    If @error = $_IESTATUS_Success Then
        ; get window title
        $hwnd = _IEPropertyGet($oIE, "hwnd")
        $title = WinGetTitle($hwnd)

        ;strip off trailing browser text
        $i = StringInStr($title, ' - ', 0, -1)
        If $i > 0 Then
            $title = StringLeft($title, $i - 1)
        EndIf

        $oIE = _IEAttach($title, "windowtitle")
    EndIf

    Return $oIE
EndFunc

 

Link to comment
Share on other sites

Thanks for your answer.

 

Here is a sample of code I used with your function (I added inside a ConsoleWrite) :

<snip>

Here are the results:

Google
Google
Google

Whereas it was supposed to give "Google | Yahoo | Google"

Any thoughts ?

Edited by JLogan3o13
Link to comment
Share on other sites

  • Moderators

@Xema, Danp2 is quite right. Please read through the forum rules, especially the part on game automation, before you post again.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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