Jump to content

_IELinkClickByText / _IELinkGetCollection


Recommended Posts

hi masters, im new here and im learning this autoit for about 1 week now. i just had a little problem about this code.

what i want is to click the link within the text of "PDA" but it happens it isnt working. what are the things i need

to be able to fix it.if theres other way like IEgetobjectbyname or any other solution will be much appriciated. TIA.. sory for my bad english i hope you guys understand it. =)

#include <IE.au3>

$oIE = _IENavigate("http://123.xxx.x.x/logon2.htm?mac_esn=0a003ed912345")
$sMyString = "PDA"
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

IE source below.

<div id='menu'>
<a class='menu' id='menuselect' href="main.cgi?

mac_esn=0a003e091234&amp;catindex=0&amp;pageindex=1&amp;Session=6020">Home</a>
<a class='menu'  href="main.cgi?

mac_esn=0a003e091234&amp;catindex=1&amp;pageindex=0&amp;Session=6020">Configuration</a>
<a class='menu'  href="main.cgi?

mac_esn=0a003e091234&amp;catindex=2&amp;pageindex=0&amp;Session=6020">Statistics</a>
<a class='menu'  href="main.cgi?

mac_esn=0a003e091234&amp;catindex=3&amp;pageindex=0&amp;Session=6020">Tools</a>
<a class='menu'  href="main.cgi?

mac_esn=0a003e091234&amp;catindex=4&amp;pageindex=0&amp;Session=6020">Logs</a>
<a class='menu'  href="main.cgi?

mac_esn=0a003e091234&amp;catindex=5&amp;pageindex=0&amp;Session=6020">Account</a>
<a class='menu'  href="main.cgi?

mac_esn=0a003e091234&amp;catindex=7&amp;pageindex=0&amp;Session=6020">PDA</a>
<a class='menu'  href="main.cgi?

mac_esn=0a003e091234&amp;catindex=8&amp;pageindex=0&amp;Session=6020">Copyright</
Link to comment
Share on other sites

Define "isn't working". What does it do. Add _IEErrorHandlerRegister() to the script and run it in SciTE to see the errors reported in the console.

:unsure:

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

Define "isn't working". What does it do. Add _IEErrorHandlerRegister() to the script and run it in SciTE to see the errors reported in the console.

:unsure:

tnx mellow..

i dont have any errors when i run the script but the thing is there is no reply/return(duno what to call it) i mean it runs fine but i want this line/link to be clicked

mac_esn=0a003e091234&amp;catindex=7&amp;pageindex=0&amp;Session=6020">PDA</a>

<a class='menu' href="main.cgi?

if you look at the source in my post it is <DIV> and i cant find in that line its ID coz all

of them are like this "<div id='menu'>" i dont know what call should i use.is it IEGetObjByID? all i want is when iENavigate http://123.xxx.x.x/logon2.htm?mac_esn=0a003ed912345 it will automaticaly click the "PDA" with the link of mac_esn=0a003e091234&amp;catindex=4&amp;pageindex=0&amp;Session=6020.

i hope u understand what im trying to say.. tnx again and sory for my grammars.

Link to comment
Share on other sites

Could you post the entire html code of the page ?

here it is.(edited text for security reason.) thank u so much..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<link rel="stylesheet" type="text/css" href="_xxxx.css?mac_esn=0a003xxxx" media="screen" />
<link rel="stylesheet" type="text/css" href="_xxxxpda.css?mac_esn=0a003xxxx" media="handheld" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Pragma" content="no-cache" />
<title>
 General Status
 [user-admin] 
</title>
<script type='text/javascript' src='Utils.js?mac_esn=0a003xxxx'></script>
<script type='text/javascript' src='Refresh.js?mac_esn=0a003xxxx'></script>
</head>
<body onload="handleLoad(0, '0a003exxxx'); window.status='Logged in as user-admin'; " onunload="handleUnload(); ">
<div class='logo'><a href='http://www.xxx.com'><img class='logo' src='_xxx.jpg?mac_esn=0a003xxxx' alt='Logo' /></a></div>
<div id='menu'>
<a class='menu' id='menuselect' href="main.cgi?mac_esn=0a003xxxx&amp;catindex=0&amp;pageindex=1&amp;Session=26599">Home</a>
<a class='menu'  href="main.cgi?mac_esn=0a003xxxx&amp;catindex=1&amp;pageindex=0&amp;Session=26599">Configuration</a>
<a class='menu'  href="main.cgi?mac_esn=0a003exxxx&amp;catindex=2&amp;pageindex=0&amp;Session=26599">Statistics</a>
<a class='menu'  href="main.cgi?mac_esn=0a003xxxx&amp;catindex=3&amp;pageindex=0&amp;Session=26599">Tools</a>
<a class='menu'  href="main.cgi?mac_esn=0a003xxxx&amp;catindex=4&amp;pageindex=0&amp;Session=26599">Logs</a>
<a class='menu'  href="main.cgi?mac_esn=0a003xxxx&amp;catindex=5&amp;pageindex=0&amp;Session=26599">Account</a>
<a class='menu'  href="main.cgi?mac_esn=0a003xxxx&amp;catindex=7&amp;pageindex=0&amp;Session=26599">PDA</a>
<a class='menu'  href="main.cgi?mac_esn=0a003xxxx&amp;catindex=8&amp;pageindex=0&amp;Session=26599">Copyright</a>
<a class='menu' href="logoff.cgi?mac_esn=0a003xxxx&amp;catindex=0&amp;pageindex=1&amp;Session=26599">Logoff</a>
<div id="userid">Account: user-admin <br /> Level: ADMINISTRATOR</div>
</div>
<div id='tabandpage'>
<div id='tabs'>
<a class='tab' id='tabbed' href="main.cgi?mac_esn=0a003xxxx&amp;catindex=0&amp;pageindex=1&amp;Session=26599">General Status</a>
<a class='tab'  href="main.cgi?mac_esn=0a003xxxx&amp;catindex=0&amp;pageindex=4&amp;Session=26599">Event Log</a>
<a class='tab'  href="main.cgi?mac_esn=0a003xxxx&amp;catindex=0&amp;pageindex=5&amp;Session=26599">Network Interface</a>
<a class='tab'  href="main.cgi?mac_esn=0a003xxxx&amp;catindex=0&amp;pageindex=6&amp;Session=26599">Layer 2 Neighbors</a>
</div>
<div id='page'>
<h1>Home => General Status</h1>
<h2>TITLE OF BLAH...BLAHH..BLAHH....  </h2>
<div class='reboot'><span class='RebootString'></span></div>
<div class='section' id='SectionDeviceInfo'>
<h2 class='sectiontitle'>Device Information</h2>
<table class='section'>
<tbody>
<tr class='dualitem'><td class='sectionlefttop'>Device Type :</td>
<td class='sectionrighttop'><div class='tablewrapper'>
<span class='var str' id='DeviceString'>
TITLE OF BLAH...BLAHH..BLAHH....
</span>
 
<span class='var str' id='PlugString'>
 
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'>Software Version :</td>
<td class='sectionright'><div class='tablewrapper'>
<span class='var str' id='SwVersion'>
BLAH..BLAH....
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'>Software BOOT Version :</td>
<td class='sectionright'><div class='tablewrapper'>
<span class='var str' id='SwBootVersion'>
BLAH..BLAHHH..
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'>Board Type :</td>
<td class='sectionright'><div class='tablewrapper'>
<span class='var str' id='BoardType'>
XP1542123
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'>awts Version :</td>
<td class='sectionright'><div class='tablewrapper'>
<span class='var str' id='awtsVersion'>
0611241812
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'>a :</td>
<td class='sectionright'><div class='tablewrapper'>
<span class='var str' id='a'>
00:51:31
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'>System Time :</td>
<td class='sectionright'><div class='tablewrapper'>
<span class='var str' id='SystemTime'>
00:23:07 01/04/2001
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'>watah :</td>
<td class='sectionright'><div class='tablewrapper'>
<span class='var str' id='wata'>
watapak
</span>
</div></td></tr>
</tbody>
</table>
</div>
<div class='section' id='watapaksyet'>
<h2 class='sectiontitle'>watapaksyet</h2>
<table class='section'>
<tbody>
<tr class='dualitem'><td class='sectionlefttop'>Status :</td>
<td class='sectionrighttop'><div class='tablewrapper'>
<span class='var str' id='Status'>
SCAN  
</span>
 
<span class='var str' id='SesRate'>
xxxxxxxxxxxxxx       
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'>Session :</td>
<td class='sectionright'><div class='tablewrapper'>
<span class='var str' id='Timer'>
00:00:00
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'>reg :</td>
<td class='sectionright'><div class='tablewrapper'>
<span class='var str' id='Reg'>
n/a
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'> Level :</td>
<td class='sectionright'><div class='tablewrapper'>
Actual: 
 
 
<span class='var int' id='Level'>
n/a
</span>
Min: 
<span class='var int' id='LevelMin'>
n/a
</span>
Max: 
<span class='var int' id='LevelMax'>
n/a
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'>hitt :</td>
<td class='sectionright'><div class='tablewrapper'>
Actual: 
 
 
<span class='var str' id='hitt'>
0
</span>
Min: 
<span class='var int' id='Min'>
0
</span>
Max: 
<span class='var int' id='rMax'>
0
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'>Air  :</td>
<td class='sectionright'><div class='tablewrapper'>
<span class='var str' id='Air'>
0
</span>
 approximately
 
<span class='var str' id='Distance'>
0.00 miles (0 feet)
</span>
</div></td></tr>
</tbody>
</table>
</div>
<div class='section' id='SectionCodes'>
<h2 class='sectiontitle'>Region Specific Information</h2>
<table class='section'>
<tbody>
<tr class='dualitem'><td class='sectionlefttop'>Regional  :</td>
<td class='sectionrighttop'><div class='tablewrapper'>
<span class='var str' id='RegionCode'>
Other
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'> Power Setting :</td>
<td class='sectionright'><div class='tablewrapper'>
<span class='var int' id='CurTxPwr'>
23
</span>
dvm
</div></td></tr>
</tbody>
</table>
</div>
<div class='section' id='InfoStats'>
<h2 class='sectiontitle'>Information</h2>
<table class='section'>
<tbody>
<tr class='dualitem'><td class='sectionlefttop'> Name :</td>
<td class='sectionrighttop'><div class='tablewrapper'>
<span class='var str' id='NameStats'>
 
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'> Contact :</td>
<td class='sectionright'><div class='tablewrapper'>
<span class='var str' id='ContactStats'>
 
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'> Location :</td>
<td class='sectionright'><div class='tablewrapper'>
<span class='var str' id='LocationStats'>
 
</span>
</div></td></tr>
</tbody>
</table>
</div>
<div class='section' id='FeaturesInfo'>
<h2 class='sectiontitle'>Features Information</h2>
<table class='section'>
<tbody>
<tr class='dualitem'><td class='sectionlefttop'>Maximum  :</td>
<td class='sectionrighttop'><div class='tablewrapper'>
<span class='var str' id='Name'>
rawr
</span>
</div></td></tr>
<tr class='dualitem'><td class='sectionleft'>Status :</td>
<td class='sectionright'><div class='tablewrapper'>
<span class='var bool' id='van'>Novan</span>
</div></td></tr>
</tbody>
</table>
</div>
</div></div>
</body>
</html>
Edited by SmOke_N
Link to comment
Share on other sites

So i try this way :

#include <IE.au3>


$_URL = "file:///" & @DesktopDir & "\source.html"
$oIE = _IECreate ( $_URL )
$sMyString = "PDA"
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerText")
    ConsoleWrite ( "-->-- $sLinkText : " & $sLinkText & @Crlf )
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

console give :

-->-- $sLinkText : 0

-->-- $sLinkText : Home

-->-- $sLinkText : Configuration

-->-- $sLinkText : Statistics

-->-- $sLinkText : Tools

-->-- $sLinkText : Logs

-->-- $sLinkText : Account

-->-- $sLinkText : PDA

And script click well when "PDA" is found !

But i can't see if it 's the good page who is opened...Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

actually this is my script.. and i dont know how to put your script in mine =) im just about 5 days learning this thing honestly and i dont have any background in scripting. tnx again..

#include <IE.au3>
$oIE = _IECreate("http://169.xxx.x.x/logon2.htm?mac_esn=0a003exxxx")
$oForms = _IEFormGetCollection ($oIE)
For $oForm In $oForms
$o_form = $oForm
Next

$o_login = _IEFormElementGetObjByName ($o_form, "Username")
$o_password = _IEFormElementGetObjByName ($o_form, "Password")
$o_signin = _IEFormElementGetObjByName ($o_form, "ok")

$username = "MyUsername"
$password = "MyPassword"

_IEFormElementSetValue ($o_login, $username)
_IEFormElementSetValue ($o_password, $password)
_IEAction ($o_signin, "click")
Link to comment
Share on other sites

#include <IE.au3>
$oIE = _IECreate("http://169.xxx.x.x/logon2.htm?mac_esn=0a003exxxx")
$oForms = _IEFormGetCollection ($oIE)
For $oForm In $oForms
$o_form = $oForm
Next

$o_login = _IEFormElementGetObjByName ($o_form, "Username")
$o_password = _IEFormElementGetObjByName ($o_form, "Password")
$o_signin = _IEFormElementGetObjByName ($o_form, "ok")

$username = "MyUsername"
$password = "MyPassword"

_IEFormElementSetValue ($o_login, $username)
_IEFormElementSetValue ($o_password, $password)
_IEAction ($o_signin, "click")
_IELoadWait($oIE)

$sMyString = "PDA"
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerText")
    ConsoleWrite ( "-->-- $sLinkText : " & $sLinkText & @Crlf )
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

Somethin like this?

Link to comment
Share on other sites

  • 1 year later...

This is not a reply to this topic as much as it is a question along the same lines. I am attempting to click a link by text, but the link text has line breaks in it and so far I have not been able to get it to work in anyway and clicking the link by index is not stable, because if there is a popup message that day, there are links in it and it changes the link index.

I am using the command very direct, because my code has already brought me to the page.

My last attempt to get the code to work:

_IELinkClickByText($oIE, "PLACE YOUR AD" & @CRLF & @CRLF & "ADVERTISING" & @CRLF & "OPTIONS!")

Here is the source for the link:

<b><A href="ad_options.asp?username=daymond&CD=7DC-7-4-F-2F|64CCACDCCDEC70CCACD0CA6C">PLACE YOUR AD<br><br>ADVERTISING<br>
            OPTIONS</A><I>!<br>
   </I></b>

How can this be made to work? I feel as though I have attempted everything, but know that I must be missing something.

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