找回密码
 加入
搜索
查看: 5505|回复: 15

[经典]这个路由器网页的按钮如何点击?

[复制链接]
发表于 2008-10-23 22:04:08 | 显示全部楼层 |阅读模式

上为图示,下为网页源文件:不胜感谢
;右边========================================================
<HTML><HEAD><META NAME=Copyright CONTENT="Copyright (c) 2003 huawei3com Corporation. All Rights Reserved."><META http-equiv=Content-Type content=text/html;charset=gb2312><META HTTP-EQUIV=Pragma CONTENT=no-cache><TITLE>Advanced Status</TITLE><LINK href=globe.css type=text/css rel=stylesheet>
<SCRIPT language=JavaScript src=utils.js></SCRIPT>
<SCRIPT language=JavaScript>
var conType=new Array("静态 IP","动态 IP","PPPoE", "PPTP", "802.1x客户端");
var state=new Array("停用","启用");
var conStat=new Array("未连接", "连接成功", "连接中...", "未连接", "未验证", "已验证","验证中...", "拨号的用户名或密码错误");

cableDSL=1
wanIP="218.18.79.148" ;
subMask="255.255.255.255" ;
gateWay="218.17.83.1" ;
dname="" ;
conntime=100540;
conTypeIdx="3" ;
ipAddr="192.168.0.1" ;
gateSubMsk="255.255.255.0";
dhcpServer="0";

run_code_ver= "BR204+V100R001"+","+"Tue, 18 Apr 2006 13:22:02 +0800";
boot_code_ver="V1.0.1";
hw_ver="V1.0.1";
lan_mac="00:0F:E2:09:9F:38";
wan_mac="00:0F:E2:09:9F:39";
clients="1";
uptime=" 2 天16:17:32";
rmtime=0
dns1="202.96.128.166";
dns2="202.96.134.133";
dnsEn=0;

pptpIp="0.0.0.0";
pptpNm="0.0.0.0";
pptpServer="0.0.0.0";

sData="2008 年 10 月 23 日  星期四 21:39:49";



function preSubmit(f,idx)
{   
  
   if ( idx == 1 )
   {
           addFormVar('dhcpAction', 0 );          
   }
   else if ( idx == 2 )
   {
           addFormVar('dhcpAction', 1 );
   }
   else if ( idx == 3 )
   {
           addFormVar('pppoeAct',1 );
   }
   else if ( idx == 4 )
   {
           addFormVar('pppoeAct',0 );
   }
   addFormElm('nowait',2)
   subForm(f,'/goform/aspForm','STATUS',cPage);   
}

function init()
{
        if ( cableDSL == 3 && (conTypeIdx==3 || conTypeIdx==4) )
        {
                alert ( "拨号的用户名或密码错误,请重新输入." );
        }
        else if ( cableDSL == 3 && conTypeIdx==5 )
        {
                alert ( "用户名或密码错误,请重新输入." );
        }

}
function getrefresh()
{
    if (wanIP == '0.0.0.0' || gateWay == '0.0.0.0' )
    {
        if (cableDSL == 0 && conTypeIdx==3 )
        {
            return('<meta http-equiv=refresh content=5>');
        }
        else if (cableDSL == 1 && conTypeIdx==3 )
                 return('<meta http-equiv=refresh content=5>');
        else
                return('<meta http-equiv=refresh content=5>');       
    }
    else
            return('<meta http-equiv=refresh content=30>');
    return("");
}
document.write(getrefresh());
</SCRIPT>
<SCRIPT src=helpScript.js></SCRIPT>
<SCRIPT src=navigatortab.js></SCRIPT>
<STYLE type=text/css>
<!--
.style1 {color:#0000FF}
-->
</STYLE></HEAD><BODY leftMargin=0 topMargin=0 MARGINWIDTH=0 MARGINHEIGHT=0 BORDER=0 onload=init();>
<SCRIPT language=JavaScript>buildNavigatorTab(arrStatus, 1)</SCRIPT>
<table border=0><tr><td colSpan=3>&nbsp;<tr><form name=frmSetup method=POST><td width=20>&nbsp;<td width=510>
<TABLE width=100% border=0 cellPadding=3 cellSpacing=0 bgcolor=#FFFFFF><TBODY> <TR><TD class=titleCell colspan=4>WAN 状态<SCRIPT>
  if ( conTypeIdx == 3 || conTypeIdx == 4 || conTypeIdx == 5 )
  {
          document.write ("<TR>" );
          document.write ("<TD width=29% class=textCell>使用"+conType[conTypeIdx-1]+"</TD>" );
        document.write ("<TD width=41% height=20 class=textCell><FONT color=blue>"+conStat[cableDSL]+"</font></TD>" );
        document.write ("<TD width=11% class=textCell><input type=button class=button value=' 连接 ' name=rlease onclick=preSubmit(this.form,3);></TD>" );
        document.write ("<TD width=19% class=textCell><input type=button class=button value=' 释放 ' name=rnew onclick=preSubmit(this.form,4);>" );
        document.write ("</TD></TR>" );
   }
  
   if ( conTypeIdx != 3 && conTypeIdx != 4 && conTypeIdx != 5 )
           document.write("<TR><td class=textCell>连接方式<td class=textCell>"+ conType[conTypeIdx-1] );
  
   if (conTypeIdx==2) {
                     document.write("<td width=11% class=textCell><input type=button class=button value=' 释放 ' name=rlease onclick=preSubmit(this.form,1);></td>");
                     document.write("<td width=19% class=textCell><input type=button class=button value=' 更新 ' name=rnew onclick=preSubmit(this.form,2);></td>");
                  }
                  else
                  {
                        document.write("<td width=11% class=textCell><td width=19% class=textCell>");
                }
        </SCRIPT><TR><TD class=textCell>IP 地址<TD height=20 class=textCell>
        <SCRIPT>if ( conTypeIdx==4 && wanIP == '0.0.0.0')
                {
                document.write(pptpIp);

        }else document.write(wanIP);</SCRIPT><TR><TD class=textCell>子网掩码<TD height=20 class=textCell><SCRIPT>if ( conTypeIdx==4 && wanIP == '0.0.0.0') document.write(pptpNm); else document.write(subMask);</SCRIPT><TD colspan=2 class=textCell>&nbsp;
        <TR><TD class=textCell>网关地址<TD height=20 class=textCell>
        <SCRIPT>if ( conTypeIdx==4 && wanIP == '0.0.0.0')
                        document.write(pptpServer);
                else
                        document.write(gateWay)</SCRIPT>
        <TD colspan=2 class=textCell>&nbsp;<TR><TD class=textCell>域名地址1<TD height=20 class=textCell>
        <SCRIPT>
        if (wanIP == '0.0.0.0' || gateWay == '0.0.0.0' || dns1==ipAddr )
        {
                 if ( dnsEn==0 ) dns1 = "0.0.0.0";
        }
        document.write(dns1);</SCRIPT><TD colspan=2 class=textCell>&nbsp;<TR><TD class=textCell>域名地址2<TD height=20 class=textCell>
        <SCRIPT>
        if (wanIP == '0.0.0.0' || gateWay == '0.0.0.0' || dns2==ipAddr )
        {
                 if ( dnsEn==0 ) dns2 = "0.0.0.0";
        }
        document.write(dns2);</SCRIPT><TD colspan=2 class=textCell>&nbsp; <SCRIPT> if ( conTypeIdx==2 )
               {
                       m = '<TR><TD class=textCell>DHCP剩余时间<TD class=textCell colspan=3>' + timeStr(rmtime);
                       document.write(m);
               }
   </SCRIPT><TR><TD class=textCell>MAC 地址<TD height=20 class=textCell><SCRIPT>document.write( wan_mac );</SCRIPT><TD colspan=2 class=textCell><FONT color=red>&nbsp; </FONT><TR><TD colSpan=4 height=1>&nbsp;<TR><TD class=titleCell colspan=4>LAN 状态<TR><TD class=textCell>LAN IP 地址<TD class=textCell colspan=3><SCRIPT>document.write(ipAddr)</SCRIPT><TR><TD class=textCell>LAN 子网掩码<TD class=textCell colspan=3><SCRIPT>document.write(gateSubMsk)</SCRIPT> <TR><TD class=textCell>启用DHCP服务器<TD colspan=3 class=textCell><span class=style1><SCRIPT>document.write(state[dhcpServer])</SCRIPT></span><TR><TD class=textCell>LAN口MAC地址<TD class=textCell colspan=3><SCRIPT>document.write( lan_mac );</SCRIPT><TR><TD colSpan=4 height=1>&nbsp;<TR><TD class=titleCell colspan=4>基本信息<TR><TD class=textCell>软件版本<TD class=textCell colspan=3><SCRIPT>document.write( run_code_ver );</SCRIPT><TR><TD class=textCell>引导器版本<TD class=textCell colspan=3><SCRIPT>document.write( boot_code_ver );</SCRIPT><TR><TD class=textCell>硬件版本<TD class=textCell colspan=3><SCRIPT>document.write( hw_ver );</SCRIPT><TR><TD class=textCell><TD height=20 class=textCell><TR><TD class=textCell>因特网时间:<TD class=textCell colspan=3><SCRIPT> document.write(sData);</SCRIPT></TABLE><BR>
<TABLE width=100% border=0 cellPadding=3 cellSpacing=0 bgcolor=#FFFFFF><TBODY><TR valign=top><TD class=noteCell width=100><TD class=noteCell><TD colspan=2 class=textCell>&nbsp;</TABLE><td width=100 align=right valign=top><p>&nbsp;<p><INPUT class=actButton type=button value=帮助 onclick=popHelp('help.htm#Status')><p><input name=button2 type=button class=actButton onClick=GURL('status_admin.asp') value=刷新></FORM></table></BODY></HTML>

;===================================================================================

;左边========================================================
<HTML><HEAD><TITLE>administration menu</TITLE><META content="Copyright (c) 2003 huawei3com Corporation. All Rights Reserved."
name=Copyright><META http-equiv=Content-Type content=text/html;charset=gb2312><META http-equiv=Pragma content=no-cache><!-- <link rel=stylesheet href=2col_leftNav.css type=text/css /> -->
<STYLE type=text/css>
A:link {
FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: white; FONT-FAMILY: Verdana, Arial, sans-serif; TEXT-ALIGN: left; TEXT-DECORATION: none
}
A:visited {
FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: white; FONT-FAMILY: Verdana, Arial, sans-serif; TEXT-ALIGN: left; TEXT-DECORATION: none
}
A:hover {
FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: yellow; FONT-FAMILY: Verdana, Arial, sans-serif; TEXT-ALIGN: left; TEXT-DECORATION: none
}
.button {
FONT-SIZE: 8pt; TEXT-TRANSFORM: uppercase; COLOR: black; FONT-FAMILY: Verdana,Arial; BACKGROUND-COLOR: gainsboro
}
P {
FONT-SIZE: 9pt; COLOR: black; FONT-FAMILY: Verdana, Arial
}
.upLink {
FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: #ffffff; TEXT-ALIGN: left;FONT-FAMILY: Verdana, Arial, sans-serif;
}
.child {display:none}
.Bborder {
BORDER-BOTTOM: #ffffff 1px dashed
}
.style3 {font-family: Verdana, Arial, sans-serif}
</STYLE>
<SCRIPT language=JavaScript src=utils.js></SCRIPT>
<SCRIPT language=JavaScript>
function GURL(x){ location=x}
var selected_item = new String;
var helpWindow=0;
function selectItem(item_name)
{
        if (selected_item!="")
            document.images[selected_item].src = 'item_nosel.gif';
        if (item_name!="")
            document.images[item_name].src = 'item_sel.gif';
    selected_item=item_name;
}
function pageLoaded()
{    selectItem('pic_status');
}
</SCRIPT></head><BODY bgcolor=#a6a6a6 leftMargin=0 onload=pageLoaded() topMargin=0 marginheight=0 marginwidth=0>
<table><TR><TD width=15>&nbsp;<TD>
<TABLE width=120 border=0 cellPadding=5 cellSpacing=0><form name=frmSetup method=post><TR><TD>&nbsp;<TR><TD class=Bborder><A target=main_screen href=WAN_ethernet_state.asp onclick=selectItem('pic_WAN')><IMG name=pic_WAN SRC=item_nosel.gif border=0>WAN设置</A><TR><TD class=Bborder><A target=main_screen href=LAN_DHCPS.asp onclick="selectItem('pic_LAN')"><IMG name=pic_LAN SRC=item_nosel.gif border=0>LAN设置</A><TR><TD class=Bborder><A target=main_screen href=route_static.asp onclick="selectItem('pic_route')"><IMG name=pic_route SRC=item_nosel.gif border=0>路由设置</A><TR><TD class=Bborder><A target=main_screen href=acl_site_mode.asp onclick="selectItem('pic_filter')"><IMG name=pic_filter SRC=item_nosel.gif border=0>上网控制</A><TR><TD class=Bborder><A target=main_screen href=acl_vServers_mode.asp onclick="selectItem('pic_spe')"><IMG name=pic_spe SRC=item_nosel.gif border=0>系统服务</A><TR><TD class=Bborder><A target=main_screen href=st_restart.asp onclick="selectItem('pic_sysTools')"><IMG name=pic_sysTools SRC=item_nosel.gif border=0>设备管理</A><TR><TD>&nbsp;<TR><TD class=Bborder><A target=main_screen href=status_admin.asp tppabs=status_admin.htm onclick="selectItem('pic_status')"><IMG name=pic_status SRC=item_nosel.gif border=0>状态记录</A><TR><TD class=Bborder><A target=main_screen href=ping.asp onclick="selectItem('pic_diag')"><IMG name=pic_diag SRC=item_nosel.gif border=0>诊断工具</A><TR><TD>&nbsp;<TR><TD>&nbsp;<TR><TD class=Bborder><A href=exp_frame.asp target=_top><IMG name=pic_exp SRC=item_nosel.gif border=0>快速设置...</A><TR><TD>&nbsp;<TR><TD>&nbsp;<TR><TD class="Bborder "><A href=javascript:preLogout(document.frmSetup)><IMG name=Logout SRC=item_nosel.gif border=0>退出</A></TABLE></form></table></BODY></HTML>

[ 本帖最后由 华杰 于 2008-10-25 15:19 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2008-10-23 22:14:46 | 显示全部楼层
#include <IE.au3>
$oIE = _IECreate('http://192.168.0.1/adv_frame.asp', 0, 1, 1, 1)
$oForm = _IEFormGetObjByName ($oIE, "frmSetup")
_IELinkClickByText ($oForm, " 释放 ")

这样不能成功
发表于 2008-10-24 08:41:31 | 显示全部楼层
试试这个:

#include <IE.au3>
$oIE = _IECreate('http://192.168.0.1/adv_frame.asp', 0, 1, 1, 1);
$oForm = _IEFormGetObjByName ($oIE, "frmSetup");
$oButton=_IEFormElementGetObjByName($oForm,"rnew");
_IEAction($oButton,"click");
 楼主| 发表于 2008-10-24 11:17:46 | 显示全部楼层
原帖由 gzken 于 2008-10-24 08:41 发表
试试这个:

#include
$oIE = _IECreate('http://192.168.0.1/adv_frame.asp', 0, 1, 1, 1);
$oForm = _IEFormGetObjByName ($oIE, "frmSetup");
$oButton=_IEFormElementGetObjByName($oForm,"rnew");
_IEAct ...

不行哦,里面有JS,都说实现不了.高手,等的就是你
发表于 2008-10-24 13:18:44 | 显示全部楼层
刚才没留意到你的html是会用java script生成不同的button,
如果以按钮的文本是'释放'为标准的话, 可以试试这样:

#include <IE.au3>
$oIE = _IECreate('http://192.168.0.1/adv_frame.asp', 0, 1, 1, 1);
$oForm = _IEFormGetObjByName ($oIE, "frmSetup");
$objs=_IEFormElementGetCollection($oForm);
dim $oButton=0
For $obj in  $objs
        if _IEFormElementGetValue($obj)=="释放" then
                ExitLoop;
        EndIf
        $oButton=0;
Next
If $oButton=0 Then
        MsgBox(0,"Error","Get Button Handle Error");
Else
        _IEAction($oButton,"click");
EndIf

[ 本帖最后由 gzken 于 2008-10-24 16:22 编辑 ]
 楼主| 发表于 2008-10-25 12:58:21 | 显示全部楼层
$oForm = _IEFormGetObjByName ($oIE, "frmSetup");
$objs=_IEFormElementGetCollection($oForm);

上面两句的返回值都是0?
发表于 2008-10-25 13:09:55 | 显示全部楼层
第一句为0的话就是说不能通过"frmSetup"这个名字获得form的句柄,那么第二句就不可能有效了,是不是你的IE没有加载完毕呢,不过看_IECreate的参数应该不是这个原因,方便的话贴源文件上来看看分析一下,是要IE加载完后用查看->源文件里面的内容
 楼主| 发表于 2008-10-25 13:26:38 | 显示全部楼层
<html><head><meta HTTP-EQUIV=Content-Type CONTENT=text/html;charset=gb2312><meta name=ProgId content=FrontPage.Editor.Document><title>高级设置</title></head><frameset rows=102,* cols=* framespacing=0 frameborder=0 border=0><frame name=banner scrolling=no target=contents src=title.htm marginwidth=0 marginheight=0><frameset rows=* cols=180,*><frame name=contents noresize target=main src=menu_admin.asp marginwidth=0 marginheight=0 scrolling=auto><frame name=main_screen src=status_admin.asp target=_self scrolling=auto marginwidth=0 marginheight=0></frameset><noframes><body><p>此网页使用了框架,但您的浏览器不支持框架。</body></noframes></frameset></html>
发表于 2008-10-25 13:27:08 | 显示全部楼层
代码好长,看了头晕
发表于 2008-10-25 13:40:20 | 显示全部楼层

回复 8# 华杰 的帖子

#include <IE.au3>
$oIE = _IECreate('http://192.168.0.1/adv_frame.asp', 0, 1, 1, 1);
$oFrame = _IEFrameGetObjByName($oIE,"main_screen")
;msgbox(0,"Handle of frame",$oFrame);用这个来看是否能获取frame的handle
$oForm = _IEFormGetObjByName ($oFrame, "frmSetup");
$objs=_IEFormElementGetCollection($oForm);
dim $oButton=0
For $obj in  $objs
        if _IEFormElementGetValue($obj)=="释放" then
                ExitLoop;
        EndIf
        $oButton=0;
Next
If $oButton=0 Then
        MsgBox(0,"Error","Get Button Handle Error");
Else
        _IEAction($oButton,"click");
EndIf

评分

参与人数 1金钱 +5 收起 理由
华杰 + 5 热心好朋友,支持

查看全部评分

 楼主| 发表于 2008-10-25 13:46:46 | 显示全部楼层
$oFrame = _IEFrameGetObjByName($oIE,"main_screen")
msgbox(0,"Handle of frame",$oFrame);用这个来看是否能获取frame的handle
不可以哦。返回值为空
发表于 2008-10-25 14:08:48 | 显示全部楼层
0才是获取不到,为空是msgbox显示不出来而已,不是0就可以了
 楼主| 发表于 2008-10-25 14:20:52 | 显示全部楼层
但最终还是点不到。
发表于 2008-10-25 14:39:19 | 显示全部楼层

回复 13# 华杰 的帖子

倒。。。

那$oButton有没有成功获取呢?
是不是form不在main_screen frame。
在不行就用msgbox来单步调试。
发表于 2008-10-25 14:43:33 | 显示全部楼层
'http://192.168.0.1/adv_frame.asp'
这个显示什么? 我看你给的网页里面两个frame,
其实如果在单个网页这个按钮很容易点,直接

$oButton = _IEGetObjByName ($obj, "rlease")
_IEAction ( $oButton, "click")

所以你应该先通过 _IEFrameGetObjByName ( ByRef $o_object, $s_name ) 得到$obj(frame的对象)
或者_IEGetObjByName ( ByRef $o_object, $s_Id [, $i_index = 0] )得到$obj(frame的对象)

不用去找form

评分

参与人数 1金钱 +5 收起 理由
华杰 + 5 热心好朋友,支持!

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-10 10:46 , Processed in 0.090569 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表