También probé viendo los forms que hay con IETab y obtenerlos por nombre pero me dió Error from function _IEFormGetObjByName, $_IEStatus_InvalidDataType. Finalmente probé obtener el conjunto de los tags INPUT y me dió Error from function _IETagNameGetCollection, $_IEStatus_InvalidDataType. ¿Cómo clickeo el botón de desconectar?
Este es el código del botón de desconectar:
Código: Seleccionar todo
<INPUT class=btnl onclick=preSubmit(this.form,4); type=button value=Disconnected name=rnew>
Este es el código fuente de mi router:
Código: Seleccionar todo
<HTML><HEAD><TITLE>Router Setup</TITLE></HEAD><FRAMESET border=0 frameSpacing=0 rows=0,* frameBorder=NO><FRAME name=transparent><FRAME name=main src="sys_status.htm"></FRAMESET></HTML>
Código: Seleccionar todo
<HTML><HEAD><TITLE>System | Status</TITLE>
<META http-equiv=Pragma content=no-cache>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<SCRIPT language=JavaScript src="utils.js"></SCRIPT>
<SCRIPT language=JavaScript src="spec.js"></SCRIPT>
<SCRIPT language=JavaScript>
var conType=new Array("Static IP","Dynamic IP","PPPoE","PPTP","L2TP","DHCP Proxy");
var state=new Array("Disable","Enabled");
var conStat=new Array("Disconnected", "Connected", "Connecting");
cableDSL="1" ;
wanIP="1**.**.1*0.**" ;
subMask="************" ;
gateWay="***********" ;
dns1="************" ;
dns2="2************" ;
dname="" ;
conntime="25049" ;
conTypeIdx="3" ;
ipAddr="***********" ;
gateSubMsk="*************";
dhcpServer="1";
firewall="1";
NAT="1";
run_code_ver="V"+"**********";
boot_code_ver="V"+"********";
hw_ver="V"+"*************";
hw_sn="***********************";
lan_mac="**************";
wan_mac="***************";
clients="2";
uptime="1304986";
curtime="1280066729";
rmtime="0";
sData = new Array(
"0","0","7/25/2010","14:5:29","","","",""
);
function preSubmit(f,idx) {
var f=document.frmSetup;
f.action.value=idx
f.submit() ;
}
function init(f)
{
}
</SCRIPT>
<LINK href="style.css" type=text/css rel=stylesheet></HEAD>
<BODY vLink=#000000 aLink=#000000 link=#000000 leftMargin=0 topMargin=0 onload=init(document.frmSetup); MARGINWIDTH="0" MARGINHEIGHT="0">
<SCRIPT>pageHead();</SCRIPT>
<TABLE height=106 cellSpacing=0 cellPadding=0 width="100%" bgColor=#142a84>
<TBODY>
<TR>
<TD>
<TR>
<TD vAlign=center bgColor=#142a84 colSpan=13 height=79>
<TABLE cellSpacing=0 cellPadding=0 width=204 border=0>
<TBODY>
<TR>
<TD width=48></TD>
<TD><IMG height=58 src="images/name.jpg" border=0></TD></TR></TBODY></TABLE></TD></TR></TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 width="100%" bgColor=#465f88>
<TBODY>
<TR class=menu1>
<TD width=20 height=27></TD>
<TD><A href="wizard.htm"> Wizard </A></TD>
<TD> System </TD>
<TD><A href="wan_mode.htm"> WAN </A></TD>
<TD><A href="lan_dhcps.htm"> LAN </A></TD>
<TD><A href="nat_vserv.htm"> NAT </A></TD>
<TD><A href="fw_opt.htm"> Firewall </A></TD>
<TD><A href="rt_table.htm"> Routing </A></TD>
<TD><A href="upnp_config.htm"> UPnP </A></TD>
<TD><A href="ddns_config.htm"> DDNS </A></TD>
<TD><A href="javascript:preLogout();"> Logout</A></TD>
<TD width="40%"> </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE>
<TBODY>
<TR>
<TD class=title1 height=40>System Settings</TD></TR></TBODY></TABLE>
<HR width="100%" SIZE=1>
<TABLE height=300>
<TBODY>
<TR>
<TD vAlign=top width=150>
<TABLE class=menu2 cellSpacing=0 cellPadding=3 width="100%">
<TBODY>
<TR>
<TD width=16 height=12></TD>
<TD noWrap> System Status</TD></TR>
<TR>
<TD width=16 height=12></TD>
<TD noWrap> <A href="sys_name.htm">System Settings</A></TD></TR>
<TR>
<TD width=16 height=12></TD>
<TD noWrap> <A href="sys_admin.htm">Administrator Settings</A></TD></TR>
<TR>
<TD width=16 height=12></TD>
<TD noWrap> <A href="sys_upgrade.htm">Firmware Upgrade</A></TD></TR>
<TR>
<TD width=16 height=12></TD>
<TD noWrap> <A href="sys_config.htm">Configuration Tools</A></TD></TR>
<TR>
<TD width=16 height=12></TD>
<TD noWrap> <A href="sys_log.htm">System Log</A></TD></TR></TBODY></TABLE></TD>
<TD style="BORDER-LEFT: #c0c0c0 2px dashed" width=2> </TD>
<TD vAlign=top>
<TABLE width=450>
<TBODY>
<TR>
<TD class=title2 noWrap>System Status</TD>
<TD align=right><INPUT class=btn onclick='doHelp("status")' type=button value=" Help "></TD></TR></TBODY></TABLE>
<FORM name=frmSetup action=do_cmd.htm method=post><INPUT type=hidden value=WAN_CON name=CMD> <INPUT type=hidden value=sys_status.htm name=GO> <INPUT type=hidden name=action>
<TABLE class=text1 cellSpacing=2 cellPadding=3 width="75%">
<TBODY>
<TR>
<TD class=title3>INTERNET</TD>
<TD align=right><INPUT class=btn onclick=location=cPage type=button value=Refresh td <> </TD>
<TR>
<TD class=item1 width="30%">Cable/DSL</TD>
<TD class=value1 width="40%">
<SCRIPT>document.write(conStat[cableDSL])</SCRIPT>
Connected </TD></TR>
<TR>
<TD class=item1>WAN IP</TD>
<TD class=value1>
<SCRIPT>document.write(wanIP)</SCRIPT>
190.64.150.72 </TD></TR>
<TR>
<TD class=item1>Subnet Mask</TD>
<TD class=value1>
<SCRIPT>document.write(subMask)</SCRIPT>
255.255.255.255 </TD></TR>
<TR>
<TD class=item1>Gateway</TD>
<TD class=value1>
<SCRIPT>document.write(gateWay)</SCRIPT>
200.40.22.2 </TD></TR>
<TR>
<TD class=item1>DNS</TD>
<TD class=value1>
<SCRIPT>document.write(dns1)</SCRIPT>
200.40.220.245 </TD></TR>
<TR>
<TD class=item1>Secondary DNS</TD>
<TD class=value1>
<SCRIPT>document.write(dns2)</SCRIPT>
200.40.30.245 </TD></TR>
<TR>
<TD class=item1>Domain Name</TD>
<TD class=value1>
<SCRIPT>document.write(dname)</SCRIPT>
</TD></TR>
<TR>
<TD class=item1>Connection Type</TD>
<TD class=value1>
<SCRIPT>document.write(conType[conTypeIdx-1])</SCRIPT>
PPPoE </TD></TR>
<SCRIPT>
if ((conTypeIdx==2)||(conTypeIdx==3)||(conTypeIdx==4)||(conTypeIdx==5))
{
document.write("<tr><td class=item1>Connection Time</td>");
document.write("<td class=value1>");
document.write(timeStr(conntime));
document.write("</td></tr>");
}
</SCRIPT>
<TR>
<TD class=item1>Connection Time</TD>
<TD class=value1>06:57:29</TD></TR>
<SCRIPT>
if (conTypeIdx==2)
{
document.write("<tr><td class=item1>Remaining Time</td>");
document.write("<td class=value1>");
document.write(timeStr(rmtime));
document.write("</td></tr>");
}
</SCRIPT>
<TR>
<SCRIPT>
if (conTypeIdx==2) {
document.write("<td><input type=button class=btn value=Release name=rlease onclick=preSubmit(this.form,1);></td>");
document.write("<td><input type=button class=btn value=Renew name=rnew onclick=preSubmit(this.form,2);></td>");
}
else if (conTypeIdx == 3) {
document.write("<td><input type=button class=btnl value=Connection name=rlease onclick=preSubmit(this.form,3);></td>");
document.write("<td><input type=button class=btnl value=Disconnected name=rnew onclick=preSubmit(this.form,4);></td>");
}
else if (conTypeIdx == 4) {
document.write("<td><input type=button class=btnl value=Connection name=rlease onclick=preSubmit(this.form,5);></td>");
document.write("<td><input type=button class=btnl value=Disconnected name=rnew onclick=preSubmit(this.form,6);></td>");
}
else if (conTypeIdx == 5) {
document.write("<td><input type=button class=btnl value=Connection name=rlease onclick=preSubmit(this.form,7);></td>");
document.write("<td><input type=button class=btnl value=Disconnected name=rnew onclick=preSubmit(this.form,8);></td>");
}
</SCRIPT>
<TD><INPUT class=btnl onclick=preSubmit(this.form,3); type=button value=Connection name=rlease></TD>
<TD><INPUT class=btnl onclick=preSubmit(this.form,4); type=button value=Disconnected name=rnew></TD></TR>
<TR>
<TD colSpan=2></TD></TR>
<TR>
<TD class=title3 colSpan=2>GATEWAY</TD></TR>
<TR>
<TD class=item1>IP Address</TD>
<TD class=value1>
<SCRIPT>document.write(ipAddr)</SCRIPT>
*********************** </TD></TR>
<TR>
<TD class=item1>Subnet Mask</TD>
<TD class=value1>
<SCRIPT>document.write(gateSubMsk)</SCRIPT>
******************* </TD></TR>
<TR>
<TD class=item1>DHCP Server</TD>
<TD class=value1>
<SCRIPT>document.write(state[dhcpServer])</SCRIPT>
Enabled </TD></TR>
<TR>
<TD class=item1>NAT</TD>
<TD class=value1>
<SCRIPT>document.write(state[NAT])</SCRIPT>
Enabled </TD></TR>
<TR>
<TD class=item1>Firewall</TD>
<TD class=value1>
<SCRIPT>document.write(state[firewall])</SCRIPT>
Enabled </TD></TR>
<TR>
<TD colSpan=2></TD></TR>
<TR>
<TD class=title3 colSpan=2>INFORMATION</TD></TR><!--
<tr>
<td class=item1>Current Time</td>
<td class=value1>
<SCRIPT language=JavaScript>
document.write(curtime);
</SCRIPT>
</td>
</tr>
-->
<TR>
<TD class=item1>System Up Time</TD>
<TD class=value1>
<SCRIPT language=JavaScript>
document.write(timeStr(uptime));
</SCRIPT>
15 days 02:29:46 </TD></TR>
<TR>
<TD class=item1>System Date</TD>
<TD class=value1>
<SCRIPT language=JavaScript>
document.write(sData[2]+" "+sData[3]);
</SCRIPT>
7/25/2010 14:5:29 </TD></TR>
<TR>
<TD class=item1>Connected Clients</TD>
<TD class=value1>
<SCRIPT language=JavaScript>
document.write( clients );
</SCRIPT>
2 </TD></TR>
<TR>
<TD class=item1>Runtime Code Version</TD>
<TD class=value1>
<SCRIPT language=JavaScript>
document.write( run_code_ver );
</SCRIPT>
V2.1.2.94 </TD></TR>
<TR>
<TD class=item1>Boot Code Version</TD>
<TD class=value1>
<SCRIPT language=JavaScript>
document.write( boot_code_ver );
</SCRIPT>
V0.1.5.9 </TD></TR>
<TR>
<TD class=item1>LAN MAC Address</TD>
<TD class=value1>
<SCRIPT language=JavaScript>
document.write( lan_mac );
</SCRIPT>
********************** </TD></TR>
<TR>
<TD class=item1>WAN MAC Address</TD>
<TD class=value1>
<SCRIPT language=JavaScript>
document.write( wan_mac );
</SCRIPT>
******************* </TD></TR></TBODY></TABLE>
<SCRIPT>pageTail(' ');</SCRIPT>
<TABLE width="95%">
<TBODY>
<TR>
<TD height=40> </TD></TR>
<TR>
<TD align=right height=40></TD></TR></TBODY></TABLE></FORM></TD></TR></TBODY></TABLE></BODY></HTML>
Código: Seleccionar todo
#include <IE.au3>
#include <INet.au3>
Const $urlrouter = la url de mi router
Const $usuario = usuario
Const $contraseña = contraseña
$ventana = _IECreate($urlrouter,0,1,0)
WinWaitActive("Conectarse a "&$urlrouter)
Send($usuario)
Send("{TAB}")
Send($contraseña)
Send("{ENTER}")
_IELoadWait($ventana)
$ventana2 = _IENavigate ($ventana,"$urlrouter"&/sys_status.htm")
_IELoadWait($ventana2)
$obotons = _IETagNameGetCollection($ventana2,"INPUT")
For $oboton In $obotons
If $oboton.name = "rnew" then _IEAction($oboton,"click")
Next
_IELoadWait($ventana2)
;a partir de acá no me funciona, el resto es para lo que sigue,darle al boton de ok, conectar y desloguearme del router
$frame = _IEFrameGetObjByName($ventana,"main")
$obotons = _IETagNameGetCollection($frame,"INPUT")
For $oboton In $obotons
_IEAction($oboton,"click")
Next
_IELoadWait($ventana)
$frame = _IEFrameGetObjByName($ventana,"main")
$obotons = _IETagNameGetCollection($frame,"INPUT")
For $oboton In $obotons
If $oboton.name = "rlease" Then _IEAction($oboton,"click")
Next
_IELoadWait($ventana)
$frame = _IEFrameGetObjByName($ventana,"main")
$obotons = _IETagNameGetCollection($frame,"INPUT")
For $oboton In $obotons
_IEAction($oboton,"click")
Next
_IELoadWait($ventana)
$frame = _IEFrameGetObjByName($ventana,"main")
$obotons = _IETagNameGetCollection($frame,"A")
For $oboton In $obotons
If $oboton.href = "javascript:preLogout();" Then _IEAction($oboton,"click")
Next