Sign in to follow this  
Followers 0
VeeDub

_IELinkGetCollection

7 posts in this topic

#1 ·  Posted (edited)

Hi Dale,

From my experience with _IELinkGetCollection it seems that it can return duplicate entries (possibly if the same link is available more than once).

This may well be by design, and is not a problem for me as I sort the results and remove the duplicate links. However if this is something that you haven't considered, it might be an idea to have an option to exclude the duplicate links from the results.

VW

Edited by VeeDub

Share this post


Link to post
Share on other sites



Hi Dale,

From my experience with _IELinkGetCollection it seems that it can return duplicate entries (possibly if the same link is available more than once).

This may well be by design, and is not a problem for me as I sort the results and remove the duplicate links. However if this is something that you haven't considered, it might be an idea to have an option to exclude the duplicate links from the results.

VW

Any reason why your sending a personal message to the public in the support forum?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Any reason why your sending a personal message to the public in the support forum?

It's not meant to be a PM, it's a public message that I've addressed to Dale as he is the author of IE.au3 and I expect that he would respond to this question.

But it's a fair point that you make, since I intended the message to be public, I should have posted without addressing to Dale directly. :P

Thanks

VW

Share this post


Link to post
Share on other sites

It's not meant to be a PM, it's a public message that I've addressed to Dale as he is the author of IE.au3 and I expect that he would respond to this question.

But it's a fair point that you make, since I intended the message to be public, I should have posted without addressing to Dale directly. :nuke:

Thanks

VW

Thought it may have been a brain fart like I've done. Maybe you thought you were actually in the control panel :P... anyway... gl with your answer.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

@VeeDub - This is by design and I doubt an option will be added to change this.

Here is a quick example of how to filter out duplicates without sorting.

#include <IE.au3>
#include <Array.au3>

Dim $aLinks[1], $i = 1

$sURL = "www.autoitscript.com"
$oIE = _IECreate($sURL)
$oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    ReDim $aLinks[$i + 1]
    $aLinks[$i] = $oLink.href
    $i += 1
Next

$aLinks[0] = UBound($aLinks) - 1

_ArrayDisplay($aLinks, "Input")
_Array1MakeUnique($aLinks)
_ArrayDisplay($aLinks, "Output")

;===============================================================================
;
; Function Name:    _Array1MakeUnique
; Description:      Takes an array and removes all duplicate items.
; Author(s):        blindwig
;
;===============================================================================
;
Func _Array1MakeUnique(ByRef $aIn, $iBase = 1, $CaseSense = 0)
    If UBound($aIn, 0) <> 1 Then
        SetError(1)
        Return
    EndIf

    If $iBase Then
        $iBase = 1
        $iInTop = $aIn[0]
    Else
        $iBase = 0
        $iInTop = UBound($aIn) - 1
    EndIf
    
    Local $aTemp[$iInTop + 2 - $iBase][2], $i
    For $i = $iBase To $iInTop
        $aTemp[0][0] = $aTemp[0][0] + 1
        $aTemp[$aTemp[0][0]][0] = $aIn[$i]
        $aTemp[$aTemp[0][0]][1] = $i
    Next
    _ArraySort($aTemp, 0, 1, $aTemp[0][0], 2, 0)

    Local $Skip = 0
    $i = $iBase
    While $i <= $aTemp[0][0] - $Skip
        While $i + $Skip + 1 <= $aTemp[0][0] And ((Not $CaseSense And $aTemp[$i][0] = _
                $aTemp[$i + $Skip + 1][0]) Or ($CaseSense And $aTemp[$i][0] == $aTemp[$i + $Skip + 1][0]))
            If $aTemp[$i][1] > $aTemp[$i + $Skip + 1][1] Then
                $aTemp[$i][0] = $aTemp[$i + $Skip + 1][0]
                $aTemp[$i][1] = $aTemp[$i + $Skip + 1][1]
            EndIf
            $Skip = $Skip + 1
        WEnd
        $i = $i + 1
        If $Skip And $i + $Skip <= $aTemp[0][0] Then
            $aTemp[$i][0] = $aTemp[$i + $Skip][0]
            $aTemp[$i][1] = $aTemp[$i + $Skip][1]
        EndIf
    WEnd
    $aTemp[0][0] = $i - 1
    ReDim $aTemp[$i][4]

    _ArraySort($aTemp, 0, 1, $aTemp[0][0], 2, 1)
    If $iBase Then
        ReDim $aIn[$aTemp[0][0] + 1]
        $aIn[0] = $aTemp[0][0]
    Else
        ReDim $aIn[$aTemp[0][0]]
    EndIf
    For $i = 1 To $aTemp[0][0]
        $aIn[$i - (1 - $iBase) ] = $aTemp[$i][0]
    Next
EndFunc   ;==>_Array1MakeUnique

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

@VeeDub - This is by design and I doubt an option will be added to change this.

Correct. _IELinkGetCollection uses the DOM's built-in "Links" collection.

Although I think I understand your desire, the question arises "What makes two links duplicate?". Two links can have the same href URL, but different link text or CSS attributes. They can also have unique events tied to them (like onclick events or onmouseover events). Any of these attributes may make you want to treat them independantly even though by one measure they are duplicates.

Dale

Edit: typos

Edited by DaleHohm

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

Correct. _IELinkGetCollection uses the DOM's built-in "Links" collection.

Although I think I understand your desire, the question arises "What makes two links duplicate?". Two links can have the same href URL, but different link text or CSS attributes. They can also have unique events tied to them (like onclick events or onmouseover events). Any of these attributes may make you want to treat them independantly even though by one measure they are duplicates.

OK, I understand.

I'm not too concerned about the sorting, but I'll have a look at the filter function in any case.

Cheers,

VW

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