Xema

How to get innertext of IE tab

8 posts in this topic

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

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

I found what was wrong, it was happening too fast!

After adding some delays, it all worked out.

And I used your function in my main project, and it works as well.

Many thanks!

Share this post


Link to post
Share on other sites

Glad the function worked for you. Still curious what web site you are accessing with 50 tabs.

Share this post


Link to post
Share on other sites

Oh. I was doing a spectacting bot for Pokemon Showdown. At the moment, there are 50-ish high elo games running at the same time.

Share this post


Link to post
Share on other sites

I was guessing it was something like that. You should read the forum rules before posting again on this subject.

Share this post


Link to post
Share on other sites

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


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.