Jump to content

Can you right click using _IELinkClinkbyIndex


stolie
 Share

Recommended Posts

Hi to all

I'm using the below to click on various links within a web page (ie: link number 27) and save the page. This obviously opens the page, which im trying to avoid to make it faster. Can i use _IELinkClickByIndex to right click this somehow?

Also, i have a series of links to access and save the data from, instead of repeating the "_IELinkClickByIndex ($oIE, 27, 1)", changing 27 to 28 etc, can i assign a variable to it. I have been trying but have failed, and i thinks its my lack of understanding thats stopping me at the moment

CODE

#include <IE.au3>

$oIE=_IECreate("http://www.mywebpage.."

$title = WinGetTitle("Microsoft Internet Explorer")

$oLinks = _IELinkGetCollection ($oIE)

Opt("WinTitleMatchMode", 2)

WinActivate($title)

; i want to loop the following allowing me to count from (link) 27 to 58

_IELinkClickByIndex ($oIE, 27, 1)

Send("!f")

Send("a")

Send("{TAB}")

Send("{down}")

Send("{down}")

Send("{Enter}")

Send("{Enter}")

On a side note,

I know there are other ways to approach this rather then the way i have, I've been trolling through the posts and help files for hours trying to figure it out.

I don't think i can use the so _ielinkclickbytext as the text shown is not consistent.

I think i could use the href links, as they all start eg:"http://www.mywebpage.adnumber_{varies from here}". There are 22 per page (but upwards of 70 others on the actual page)

Each of those 22 links will need to be saved in html/mht format. (eg: like when you right click on a link as select 'save as')

Any assistance/mini examples for me to work from would be appreciated.

Thanks in advance

Link to comment
Share on other sites

Can i use _IELinkClickByIndex to right click this somehow?

No. And if it were possible, it'd be 100% useless. (IMO)

Also, i have a series of links to access and save the data from, instead of repeating the "_IELinkClickByIndex ($oIE, 27, 1)", changing 27 to 28 etc, can i assign a variable to it. I have been trying but have failed, and i thinks its my lack of understanding thats stopping me at the moment

CODE

#include <IE.au3>

$oIE=_IECreate("http://www.mywebpage.."

$title = WinGetTitle("Microsoft Internet Explorer")

$oLinks = _IELinkGetCollection ($oIE)

Opt("WinTitleMatchMode", 2)

WinActivate($title)

; i want to loop the following allowing me to count from (link) 27 to 58

_IELinkClickByIndex ($oIE, 27, 1)

Send("!f")

Send("a")

Send("{TAB}")

Send("{down}")

Send("{down}")

Send("{Enter}")

Send("{Enter}")

Ok... if I don't get it wrong.. what you want to do is save the page that those links go to in an .html file. If you were able to use _IELinkClickByIndex () to right click on a link, the rest of the code will work sometimes.. sometimes it won't.. remember that the explorer window will need focus and you can't even touch your mouse. Not to mention that the link you are trying to right.click might be out of the screen... What you should do is follow the next example and adapt it to your needs:

#include <IE.au3>
#include <INet.au3>
;Create the explorer
$oIE = _IECreate ("www.autoitscript.com")
;This part can totally be removed, since is only to display the number of links and where they link to
    ;Get link collection
    $oLinks = _IELinkGetCollection ($oIE)
    $iNumLinks = @extended
    MsgBox(0, "Link Info", $iNumLinks & " links found")
    For $oLink In $oLinks
        MsgBox(0, "Link Info", $oLink.href)
    Next
;=========================================================================================================

MsgBox(0,"","Now we'll save the source code of all links from index 0 to 5")
;Loop from index 0 to 5
For $i=0 To 5
    $sLink=_IELinkGetCollection ($oIE,$i);Get the $i-indexed link
    ;MsgBox(0,"",$sLink.href);Shows you the link that it's saving
    $sSource=_INetGetSource($sLink.href);Get the source code of the link
    FileWrite("Page no. " & $i & ".html",$sSource);Write the html file with the source
Next

MsgBox(0,"","Done! :-)")

Notice that this script is 100% independent of the window state. So, you can create it hidden or minimize it and it will do its job while you chat with your friends. <_<

-edit- typos.

Edited by Nahuel
Link to comment
Share on other sites

Thanks for your reply.

I tried your example and got it to work, but extrememly slowely. Also i had an Proxy error and thus didnt get the apt results (probably something to do with security issues via work servers?)

I have further researched into InetGet(). Do you think this might work

Link to comment
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
 Share

  • Recently Browsing   0 members

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