Sign in to follow this  
Followers 0
M4th3u534

Help with Link Click

28 posts in this topic

#1 ·  Posted (edited)

Hello guys, i need some help on this:

I got a script that i want it to click on every link on IExplorer only if the the link is NOT named "Example1".

Like this:

Got a link at a webpage and it says "Example1" and i want to click every link except that one.. All others are included..

If you guys don't understand what i want tell me and i will try to explain it again. Thanks everybody.

Edited by M4th3u534

Share this post


Link to post
Share on other sites



Welcome to AutoIt and the forum!

Can you please tell us why you need to click all links on a page?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks, and the reason is that i need to test multiple links on my website but not this one "Example1".. You think you can help me?

Share this post


Link to post
Share on other sites

Which browser do you use? Internet Explorer?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I use chrome actually but for AutoIt im using Internet Explorer...

Share this post


Link to post
Share on other sites

For Internet Explorer there comes a UDF with AutoIt. Funktion _IELinkGetCollection returns a collection of all links. Loop through the collection and "click" on the URLs.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

You wouldnt have any little example to show me would you :) ? sorry for bothering you that much ..

Share this post


Link to post
Share on other sites

The Help file has example code for just about every function in it. There is also examples in the Wiki.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Hey guys im back and i think i got it working the only thing that isnt right is that it always clicks in the same link instead of going to the next one.. any ideas to solve this?

this is what im going with so far..

Local $sMyString = $aArray[1]
Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
Local $sLinkText = _IEPropertyGet($oLink, "innerText")
If Not StringInStr($sLinkText, $sMyString) Then
_IEAction($oLink, "click")
ExitLoop
EndIf
Next

Share this post


Link to post
Share on other sites

I see nothing wrong with the script. Looks exactly like the example in _IELinkClickByText,


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Well it is working but not as i want it to.. It is not click the link named "Example1" but it only clicks in the first link in the page and keep repeating that.. doesnt follow on to the next links..

Share this post


Link to post
Share on other sites

I'm assuming that the link will open a new page...the objects in the collection will no longer be present if you navigate away from the page that houses them...you'll need to go another route.

You might just want to read all the href's of the links, and navigate to those directly in a loop (_ienavigate)


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

It opens in the same tab, then it goes back and opens the same link again.. but i will try what you said, thanks everyone for the support.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

By 'open a new page' I mean it navigates to a new page (yes, the same tab). Please let me know if it does/does not.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Hey jdelaney can you tell me how to do that what you're sayin.. sorry im not an advanced user ;/

Share this post


Link to post
Share on other sites

Another thing guys.. Can you tell me if it is possible to click in a link if a part of the link is like "example1"? something like this:

the full link is "http://www.example.com/example1.html" - But i want to click any link where "example1" appears u know what im sayin?

Thanks guys!

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

using your above example

Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
$href = $oLink.href
If StringInStr($href, "example1") Then
_IEAction($oLink, "click")
EndIf
Next
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#18 ·  Posted

using your above example

Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
$href = $oLink.href
If StringInStr($href, "example1") Then
_IEAction($oLink, "click")
EndIf
Next

Sorry for the delay, yes this will do what im looking for.. I was just wondering if this
_IEAction($oLink, "click")
could be used to open the link in another tab? Thanks in advance!

Share this post


Link to post
Share on other sites

#19 ·  Posted

Anyone? i need to know how to open the $oLink in another tab.. thanks

Share this post


Link to post
Share on other sites

#20 ·  Posted

Have you tried going to the options and see if there's an option to open all links in new tabs? I don't know, since i don't use IE.


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

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