Jump to content
Sign in to follow this  
jacob_1998_1999

Click Link By Index , IE UDF

Recommended Posts

jacob_1998_1999

; *******************************************************
; Example 1 - Open browser with basic example, get link collection,
;               loop through items and display the associated link URL references
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
$oLinks = _IELinkGetCollection ($oIE, -1)
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
For $oLink In $oLinks
    MsgBox(0, "Link Info", $oLink.href)
Next

-------------

Would it be possible to get an example showing the index Number with the URLs, and perhaps print them to a file?

Share this post


Link to post
Share on other sites
jacob_1998_1999

Would it be possible to get an example showing the index Number with the URLs, and perhaps print them to a file?

Simple way I thought to do this, Not sure if it is 100% correct.. And I will need to do a tad more research to save to a file again.

; *******************************************************
; Example 1 - Open browser with basic example, get link collection,
;               loop through items and display the associated link URL references
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
$oLinks = _IELinkGetCollection ($oIE, -1)
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
$oIndexNumber = -1
For $oLink In $oLinks
    $oIndexNumber = $oIndexNumber + 1
    MsgBox(0, "Link Info", $oLink.href & " " & $oIndexNumber)
Next

Share this post


Link to post
Share on other sites
jacob_1998_1999

Yet again,

Modified Example.

; *******************************************************
; Example 1 - Open browser with basic example, get link collection,
;               loop through items and display the associated link URL references
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
$oLinks = _IELinkGetCollection ($oIE, -1)
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
$oIndexNumber = -1
$file = FileOpen("LinkIndexs.txt", 1)
For $oLink In $oLinks
    If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
    EndIf
$oIndexNumber = $oIndexNumber + 1
;MsgBox(0, "Link Info", $oLink.href & " " & $oIndexNumber)
    FileWrite($file, $oLink.href & " " & $oIndexNumber & @CRLF)
Next
FileClose($file)
Edited by jacob_1998_1999

Share this post


Link to post
Share on other sites
jacob_1998_1999

I have gotten everything that I wanted from LinkClickByIndex -- Other than the fact that it Does NOT work (to my knowledge) When the window is brought up from the _IEcreate("http://www.Google.com", 0,0) method. Am I going about this wrong.. Or am I trying to write my project to do something that is means are not capable for yet?

Share this post


Link to post
Share on other sites
jacob_1998_1999

Perhaps found my problem..

$oButton = _IEFormElementGetObjByName($oForm, "submit")

$oButton.focus()

Send("{Enter}")

This does not go through in the "hidden" state.

HTML of the Form I am trying to get through.

    <tr><td>Username:</td><td><input name=username></td></tr>
    <tr><td>Password:</td><td><input type=password name=password></td></tr>
    <tr><td></td><td><input name=submit class=submit type=submit value='log in'</td></tr>

Can anyone think of another way to get into it?

Share this post


Link to post
Share on other sites
Andrew Sparkes

Use _IEFormSetElementValue() and _IEFormSubmit() check IE.au3 ...

Make $form,$username,$password obj references to the form and the inputs, respectively.

_IEFormSetElementValue($username,'username')

_IEFormSetElementValue($password,'password')

_IEFormSubmit($form)

EDIT: To hit the submit button, try _IEClickLinkByText() I think that's what it's called...

Sparkes.

Edited by Andrew Sparkes

---Sparkes.

Share this post


Link to post
Share on other sites
jacob_1998_1999

I just changed the .focus() + ENTER to $oButton.click() worked.

With the page I am dealing with the Index is prefered over the LinkClickByName -- Because several of the links are named the same.

Share this post


Link to post
Share on other sites
Andrew Sparkes

If you need to, just do a regex on it. That would be the simplest way... You could just parse out the link url of the link you are looking for...

Sparkes.


---Sparkes.

Share this post


Link to post
Share on other sites
jacob_1998_1999

I Do need to use a Regex for another part in this script.. But sadly I know nothing about regex at all.. A example of why I would need it is as follows:

<a href="/attack.php?UID=7357&tkid=942bb7fbd033a09be0e48ead211a2f29">Attack</a>

I would like to search the entire page for all "/attack.php?UID=" yet.. Exclude 2 specific ones.. And Simulate a click on links that are avaliable that are not the 2 I specify. Is that confusing enough? :D

Sorry for going off topic.

EDIT:

of <a href="/attack.php?UID=7357&tkid=942bb7fbd033a09be0e48ead211a2f29">Attack</a> I only need to actually search for "attack.php?UID=###&"

Edited by jacob_1998_1999

Share this post


Link to post
Share on other sites
big_daddy

I Do need to use a Regex for another part in this script.. But sadly I know nothing about regex at all.. A example of why I would need it is as follows:

<a href="/attack.php?UID=7357&tkid=942bb7fbd033a09be0e48ead211a2f29">Attack</a>

I would like to search the entire page for all "/attack.php?UID=" yet.. Exclude 2 specific ones.. And Simulate a click on links that are avaliable that are not the 2 I specify. Is that confusing enough? :D

Sorry for going off topic.

EDIT:

of <a href="/attack.php?UID=7357&tkid=942bb7fbd033a09be0e48ead211a2f29">Attack</a> I only need to actually search for "attack.php?UID=###&"

This should get you started:

Requirements:

Latest Beta

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

Dim _
        $i = 0, _
        $aLinks[1], _
        $sExclude1 = "whatever1", _
        $sExclude2 = "whatever2", _
        $sInclude = "attack.php?UID=", _
        $sURL = "www.your-webpage.com"

$oIE = _IECreate ($sURL)
; Get a collection all all links
$oLinks = _IELinkGetCollection ($oIE)
; Loop through all links
For $oLink In $oLinks
    ; Get the href value for the current link
    $sHREF = $oLink.href
    ; Check that it matches the type of links we are looking for
    If StringInStr($sHREF, $sInclude) Then
        ; Check that it do not include our excluded strings
        If Not StringInStr($sHREF, $sExclude1) And StringInStr($sHREF, $sExclude2) Then
            ReDim $aLinks[$i + 1]
            ; Build an array of all links that passed our test
            $aLinks[$i] = $sHREF
            $i += 1
        EndIf
    EndIf
Next

_ArrayDisplay($aLinks, "Matching Links")

Share this post


Link to post
Share on other sites
jacob_1998_1999

This should get you started:

That... Is beautiful man. *sheds a tear* Thank you so much..

Wow, Just ty. :D

One problem.. Something is missfiring.. I'll upload an Example.html and a little script.

Edited by jacob_1998_1999

Share this post


Link to post
Share on other sites
jacob_1998_1999

Promised files are attached.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.