Jump to content

_ielinkclickbytext partial matches?


Recommended Posts

Hi guys!

Okay... so let's just say some hypothetical person is having a lot of fun with the IE functions in autoit :)

This hypothetical person wants to have autoit click a link in IE that partially matches the string he provides. For example, assume that below are links on a web page:

*Home

*Boards

*News

*Contacts

*Departments

*Art Gallery

So, if autoit is provided the word "art" in the _IELinkClickbyText function, it will click departments if the index it is given is 0. If it is given 1, then it will click Art Gallery.

Thanks guys!

Link to comment
Share on other sites

Hi guys!

Okay... so let's just say some hypothetical person is having a lot of fun with the IE functions in autoit :)

This hypothetical person wants to have autoit click a link in IE that partially matches the string he provides. For example, assume that below are links on a web page:

*Home

*Boards

*News

*Contacts

*Departments

*Art Gallery

So, if autoit is provided the word "art" in the _IELinkClickbyText function, it will click departments if the index it is given is 0. If it is given 1, then it will click Art Gallery.

Thanks guys!

You could just hack your copy of IE.au3. Copy the _IELinkClickByText() function to a new name, i.e. _IELinkClickByString(), then change just one line inside the function:

From:

If $linktext = $s_linkText ThenoÝ÷ Ù:ºÚ"µÍYÝ[Ò[Ý  ÌÍÛ[Ý^  ÌÍÜ×Û[Õ^
H[

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 4 years later...

I cant seem to get this working... but i think it would help solve my problem here possibly →

Func _IELinkClickByString(ByRef $o_object, $s_linkText, $i_index = 0, $f_wait = 1)
If Not IsObj($o_object) Then
  __IEErrorNotify("Error", "_IELinkClickByText", "$_IEStatus_InvalidDataType")
  Return SetError($_IEStatus_InvalidDataType, 1, 0)
EndIf
;
Local $found = 0, $linktext, $links = $o_object.document.links
$i_index = Number($i_index)
For $link In $links
  $linktext = $link.outerText & "" ; Append empty string to prevent problem with no outerText (image) links
  If $linktext = $s_linkText Then?oÝ?÷ Ù:ºÚ"µÍ?Y?Ý?[?Ò[?Ý? ?ÌÍ?Û[?Ý^  ?ÌÍ?Ü×Û[?Õ^
H[
   If ($found = $i_index) Then
    $link.click()
    If $f_wait Then
     _IELoadWait($o_object)
     Return SetError(@error, 0, -1)
    EndIf
    Return SetError($_IEStatus_Success, 0, -1)
   EndIf
   $found = $found + 1
  EndIf
Next
__IEErrorNotify("Warning", "_IELinkClickByText", "$_IEStatus_NoMatch")
Return SetError($_IEStatus_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both
EndFunc
Link to comment
Share on other sites

That's a corrupted code tag, that isn't supposed to be there, which is why it's not working for you.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You could ask PsaltyDS what he wrote there, he might recall it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Just use

If StringInStr($linktext, $s_linkText) Then

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

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...