Sign in to follow this  
Followers 0
Spiff59

WinList, _IEAttach, _IETagNameGetCollection and tabs

5 posts in this topic

#1 ·  Posted (edited)

This is my first time delving into IE and HTML via Autoit, so it's all virgin ground for me and I'm sure I'm deficient conceptually in many areas.

I'm wanting to start small, so at this point I simply want to retrieve the data contained within a specific classname within <DIV> tags. Logically, it seemed the place to start this task was to make the pertinent webpage available to Autoit. There's where I ran into trouble. Didn't get very far, did I? Actually, I was able to pull the <DIV> tags, but I ran into some grief regarding IE7 tabs.

Winlist() returns the specific title for the tab that is active/focused, but regardless of the tab selected, it returns the same hWnd. Referencing that handle will only return html tags from the first tab. So, I switched to using the "Title" mode of IEAttach(), and, the strings from Winlist don't match. I find if I trim the browser name off the right (28 characters: " - Windows Internet Explorer") that IEAttach() is successful and from there I could proceed. But, something doesn't seem kosher. Can I trust that just chopping off 28 bytes from the right of the Winlist title will always work? Is there a better way to grab hold of the current/selected/focused/active IE7 tab?

I did spend an hour reading 20 threads resulting from searching this question, and another 20 minutes in the help file, including reading the IEAttach() help about 4 times. I made diversions looking into "embedded" options" and IEframe functions, but got no joy.

My target pages do contain IEFrame classes and Internet Explorer_Server control classes.

Thank you.

Edited by Spiff59

Share this post


Link to post
Share on other sites



All IE Tabs share the same top level window, the the shared hwnd.

Why the link with WinList? What are you really trying to do? Take a look at Example 5 in _IEAttach that builds an array or all browser instances... perhaps this could replace your use of WinList.

_IEAttach uses a registry location to find the suffix on the Window Title. Open IE.au3 to see what it does and what it assumes if the registry key is blank.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Is there a better way to grab hold of the current/selected/focused/active IE7 tab?

I wrote the following function earlier today. While it appears to work fine, I can't help but wonder if the functionality could be added to the existing _IEAttach function.

HTH, Dan

;===============================================================================
;
; Function Name:    _IEGetActiveTab()
; Description:      Retrieve the IE Window Object of the currently active tab
; Parameter(s):     None
; Requirement(s):   AutoIt3 V3.2 or higher
;                   On Success  - Returns an object variable pointing to the IE Window Object
;                  On Failure   - Returns 0 and sets @ERROR
;                   @ERROR      - 0 ($_IEStatus_Success) = No Error
;                               - 7 ($_IEStatus_NoMatch) = No Match
; Author(s):        Dan Pollak
;===============================================================================
;
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
        
        $i = 1

    ; loop through all available browser instances
        While 1
            $oIE = _IEAttach ("", "instance", $i)
            
            If @error = $_IEStatus_NoMatch Then 
                $oIE = ""
                ExitLoop
            EndIf

        ; See it matching title found
            If StringInStr(_IEDocReadHTML ($oIE), $title) > 0 Then
                ExitLoop
            EndIf

            $i += 1
        WEnd
    EndIf

    Return $oIE
EndFunc

Share this post


Link to post
Share on other sites

Does you function do something different than _IEAttach with windowtitle parameter?

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Does you function do something different than _IEAttach with windowtitle parameter?

Dale

Apparently not. ^_^ Thanks for pointing that out.

Share this post


Link to post
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
Sign in to follow this  
Followers 0