Sign in to follow this  
Followers 0
Dizzydbd

clicking java "link" in IE

12 posts in this topic

Any1 knows how to click this with _IE functions ?

<DIV id=da8a><A onkeydown="return false;" oncontextmenu="return false;" class=azul onfocus=blur() tabIndex=-1 onclick="clt('8');" href="javascript:void(0);"><FONT style="FONT-SIZE: 10pt" color=#e56717 face=Tahoma>Some Text</FONT> </A><FONT style="FONT-SIZE: 8pt" color=#5c5c5b face=Tahoma><BR>Some text</FONT> </DIV>

Thank you in advanced.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

_IELinkClickByText

Edited by notsure

Share this post


Link to post
Share on other sites

didn't work

Share this post


Link to post
Share on other sites

Hi,

First, I recommend you to download and install the Dubug Bar which is free for personal use.

Then use it to find the correct href name for the link you want to click and try the following code.

;Set IE Form Elements Links
    
    $oIE = _IEAttach ("Window Title or URL") ;<<<<<< Change 
    $oForm = _IEFormGetObjByName ($oIE, "mainForm")
    
    ;Set IE Links
    $oLinks = _IELinkGetCollection ($oIE)
    $iLinksCnt = @extended ;Form Tag Total Count & must be directly below tag name for correct total count

    $hrefname = "HREF Name" ;<<<<<< Change
        
    ConsoleWrite(@LF & @LF & "------- Begin Links ---------------------------------------------------------------------" & @LF)
    For $oLink In $oLinks
        If $oLink.id = $hrefname Then $ohrefname = $oLink       
        ;MsgBox(0, "Link Info", $oLink.href)
        ConsoleWrite("Links Info " & @TAB & " Link: " & $oLink.href & @TAB & " ID: " & $oLink.id & @TAB & " Name: " & $olink.Name & @LF)
    Next


_IEAction($ohrefname, "click")

jfcby


Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Share this post


Link to post
Share on other sites

sadly i get same href "javascript:void(0);" and the script is clicking the last one in the list.

Share this post


Link to post
Share on other sites

I would jump in and help here, but this is obviously turning into one of those threads where the OP sabotages the process by supplying the critical information one morsel at a time. Sorry, I'll save the frustration and wait until it is all on the table.

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

Share this post


Link to post
Share on other sites

Dale it's really not my intention to do that, if i somehow do it. I really want and could use the help.

The script is intended to refresh a page until a link like that is available and press it. The click simply executes a java script.

Also i used the _IE functions be4 in many scripts and I always found a workaround for all the issues that occurred, but in this case i just can't think at a solution.

Thank you,

Diz

Share this post


Link to post
Share on other sites

Did you successfully get an object reference to the link element yet? If not, what is your specific problem in that step? Post the code you tried for that part.

Having a reference to the link did you try _IEAction() with "click", or failing that, the "focus" followed by ControlSend() method in the examples? If you did try these, what happened, what is the specific problem in this step? Post the code you tried for this part.

:mellow:


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

Share this post


Link to post
Share on other sites

Damn i did it :mellow: And was easy too.

$oIE = _IEAttach("","URL")
$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
For $i=0 to ($iNumLinks - 1)
    $oLink = _IELinkGetCollection($oIE,$i)
    If $oLink.href = "javascript:void(0);" Then
        _IELinkClickByIndex($oIE,$i )
        Exit
        EndIf

Next

I know i could do it with "For in" but i needed it like this.

Thank you all for support.

Share this post


Link to post
Share on other sites

Hello,

I want to do something like this - click a javascript 'link' in IE, but there are several of these on the page I'm using, so the code written earlier wouldn't distinguish between them. Any ideas how I might click one specific link? Thank you!!!

Share this post


Link to post
Share on other sites

I want to do something like this - click a javascript 'link' in IE, but there are several of these on the page I'm using, so the code written earlier wouldn't distinguish between them. Any ideas how I might click one specific link?

Every property of the link can be used to find the right one. In the example above, it searched for a particular string in $oLink.href. You could just use text by _IELinkClickByText(), use a 0-based index with _IELinkClickByIndex(), or get the collection as above and walk through looking for whatever property have in mind.

:blink:


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

Share this post


Link to post
Share on other sites

Every property of the link can be used to find the right one. In the example above, it searched for a particular string in $oLink.href. You could just use text by _IELinkClickByText(), use a 0-based index with _IELinkClickByIndex(), or get the collection as above and walk through looking for whatever property have in mind.

:blink:

_IELinkClickByText is working great, thank you!

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