Jump to content

Useing IELinkClickByText to click webpage button.


 Share

Recommended Posts

I've been trying to use the IE.au3 UDF to click on the "Add to Internet Explorer" button on the following webpage:

http://www.iegallery.com/en-us/Addons/Details/813

What I thought would be a relatively simple task has me perplexed.

I cannot get _IELinkClickByText to work and have searched the entire forum for an alternate solution.

Windows 7-64 bit with IE9

Please point me in the right direction.

Thank you in advance for any help or example you can provide.

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

#include <IE.au3>
Local $String = "Add to Internet Explorer"
$oIE = _IECreate("http://www.iegallery.com/en-us/Addons/Details/813")
Local $Links = _IELinkGetCollection($oIE)
For $Link In $Links
Local $Text = _IEPropertyGet($Link, "outertext")
ConsoleWrite($Text & @CRLF)
If StringInStr($String,$Text) Then
     MsgBox(0,"Voila!","Text found!")
     ExitLoop
Else
ContinueLoop
EndIf
Next

Check if this will find it.

Edit: As i saw your button is a span...

Edited by ileandros

I feel nothing.It feels great.

Link to comment
Share on other sites

Thank you for the reply, ileandros.

Your script does find the button text "Add to Internet Explorer".

But after I added the following line of code, it does not click the button.

Am I using the wrong function?

_IELinkClickByText($oIE, $Text)

#include
Local $String = "Add to Internet Explorer"
$oIE = _IECreate("http://www.iegallery.com/en-us/Addons/Details/813")
Local $Links = _IELinkGetCollection($oIE)
For $Link In $Links
Local $Text = _IEPropertyGet($Link, "outertext")
ConsoleWrite($Text & @CRLF)
If StringInStr($String,$Text) Then
MsgBox(0,"Voila!","Text found!",1)
_IELinkClickByText($oIE, $Text)
ExitLoop
Else
ContinueLoop
EndIf
Next

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

Does this help?

Remarks

Not all elements that appear to be links actually are. It is common practice to attach onclick Javascript events to other DOM elements to simulate the behavior of links. To activate such elements, use "click" with _IEAction.

Function _IELinkClickByText - http://www.autoitscript.com/autoit3/docs/libfunctions/_IELinkClickByText.htm

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

Link to comment
Share on other sites

Hello somdcomputerguy,

I read the above earlier and have tried many different things without success.

I feel the clues are in the portion of the source code listed below.

Thanks for your help.

taurus905

<div id="download_addon"><span>
             <a href="javascript:BrowserDetectionAddonInstallSearch(&#39;/en-us/AddOns/DownloadAddOn?resourceId=813&#39;,&#39;False&#39;, &#39;813&#39;, &#39;00000000-0000-0000-0000-000000000000&#39;);" class="button orange_gradient trackDownload" id="install_addon" data-type="SearchProvider" data-name="Google Search" data-partner="Google" data-id="813">
                 Add to Internet Explorer</a>
             </span>
            
        
         </div>

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

There is something in the javascript action that is preventing a simple click action to not perform the button activation.

This code will get you further... then look at the second example for _IEAction for tips on how to deal with the popup.

Dale

#include <IE.au3>
$oIE = _IEAttach("Internet Explorer Gallery")
$oAs = _IETagnameGetCollection($oIE, "a")
for $oA in $oAs
 If StringInStr($oA.innertext, "Add to Internet Explorer") Then
  _IEAction($oA, "focus")
  $hwnd = _IEPropertyGet($oIE, "hwnd")
  ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
 EndIf
Next

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

It's a span.

I havent messed with IE for long time but try _IETagnameGetCollection()

ileandros,

Thank you for your help. You were right. _IETagnameGetCollection() was the answer.

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

There is something in the javascript action that is preventing a simple click action to not perform the button activation.

This code will get you further... then look at the second example for _IEAction for tips on how to deal with the popup.

Dale

#include <IE.au3>
$oIE = _IEAttach("Internet Explorer Gallery")
$oAs = _IETagnameGetCollection($oIE, "a")
for $oA in $oAs
If StringInStr($oA.innertext, "Add to Internet Explorer") Then
_IEAction($oA, "focus")
$hwnd = _IEPropertyGet($oIE, "hwnd")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")
EndIf
Next

Dale,

Thank you for taking the time to resolve my issue. Your example worked perfectly.

You're the man!

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

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