maoying 发表于 2009-5-19 00:20:37

一个典型的弹出窗口问题(IE类函数处理完后,不能点击弹出窗口)

本帖最后由 maoying 于 2009-5-22 22:55 编辑

[问题解决,分类改不了,麻烦版主了]
想通过Au3开无线路由

弹出如图的提示,试过很多种代码,总是点不了。图:alert.gif

代码如下:#include <IE.au3>
;-----------------点登录对话框----------------------
Run('C:\Program Files\Internet Explorer\IEXPLORE.EXE 192.168.1.1')
WinWait("Connect to 192.168.1.1","")
If Not WinActive("Connect to 192.168.1.1","") Then WinActivate("Connect to 192.168.1.1","")
WinWaitActive("Connect to 192.168.1.1","")
;Send("{ENTER}")                                                                                                      ;这个也可以
ControlClick("Connect to 192.168.1.1", "OK", "","left",1)      ;点OK按钮
;------------------操作---------------------------
$oIE = _IEAttach ("TL-WR340G 54M无线宽带路由器","Title")
$oFrame = _IEFrameGetObjByName ($oIE, "bottomLeftFrame")
_IELinkClickByText ($oFrame, "无线参数")
$oFrame = _IEFrameGetObjByName ($oIE, "mainFrame")
$oForm = _IEFormGetCollection ($oFrame, 0)
_IEFormElementCheckboxSelect ($oForm, 2, "ap", 1, "byValue")      ;开启无线功能
$oQuery = _IEFormElementGetObjByName ($oForm, "Save")
_IEAction($oQuery ,"click")                                                                                    ;点"保存"
;-----------------点登确认重启对话框-----------------
WinWait("Windows Internet Explorer", "")
If Not WinActive("Windows Internet Explorer", "") Then WinActivate("Windows Internet Explorer", "")
WinWaitActive("Windows Internet Explorer", "")
ControlClick("Windows Internet Explorer", "OK", "","left",1)
红色部分老是点不了图中的对话框

请问有什么方法吗?

NotBad 发表于 2009-5-19 11:11:36

看样子是title的问题?你的title和提示框的title不一致

pauzn 发表于 2009-5-19 12:18:06

窗口名称不对
你仔细看看是什么字母

maoying 发表于 2009-5-19 19:26:52

:face (36):
啊,对

但改完后还是照样不行,重启电脑也试过了,还是不行:face (9):
难道代码还有错?
(代码如下)
#include <IE.au3>
;-----------------点登录对话框----------------------
Run('C:\Program Files\Internet Explorer\IEXPLORE.EXE 192.168.1.1')
WinWait("Connect to 192.168.1.1","")
If Not WinActive("Connect to 192.168.1.1","") Then WinActivate("Connect to 192.168.1.1","")
WinWaitActive("Connect to 192.168.1.1","")
;Send("{ENTER}")                                                                                                        ;这个也可以
ControlClick("Connect to 192.168.1.1", "OK", "","left",1)        ;点OK按钮
;------------------操作---------------------------
$oIE = _IEAttach ("TL-WR340G 54M无线宽带路由器","Title")
$oFrame = _IEFrameGetObjByName ($oIE, "bottomLeftFrame")
_IELinkClickByText ($oFrame, "无线参数")
$oFrame = _IEFrameGetObjByName ($oIE, "mainFrame")
$oForm = _IEFormGetCollection ($oFrame, 0)
_IEFormElementCheckboxSelect ($oForm, 2, "ap", 1, "byValue")      ;开启无线功能
$oQuery = _IEFormElementGetObjByName ($oForm, "Save")
_IEAction($oQuery ,"click")                                                                                    ;点"保存"
;-----------------点登确认重启对话框-----------------
WinWait("Microsoft Internet Explorer", "")
If Not WinActive("Microsoft Internet Explorer", "") Then WinActivate("Microsoft Internet Explorer", "")
WinWaitActive("Microsoft Internet Explorer", "")
ControlClick("Microsoft Internet Explorer", "OK", "","left",1)
;ControlSend("Microsoft Internet Explorer", "OK", "","{ENTER}")

maoying 发表于 2009-5-19 21:24:52

本帖最后由 maoying 于 2009-5-19 21:26 编辑

自己顶一个
等……{:3_89:}

passkalilo 发表于 2009-5-20 16:52:39

ControlClick("Windows Internet Explorer", "OK", "","left",2)
网页对话框有时要点两下才行的
另外如果是JS弹出的对话框,必需要用多线程解决

maoying 发表于 2009-5-20 19:25:53

本帖最后由 maoying 于 2009-5-20 19:27 编辑

两下的也试过了,不行:face (35):

从window info中看是这样的,IE里的源码是<INPUT class=button id=Save type=submit value="保 存" name=Save>,不知道是不是JS

maoying 发表于 2009-5-21 22:43:28

:face (30):
想不通啊

maoying 发表于 2009-5-22 21:10:40

发现无线路由设置页面里有段代码<center><form action="WlanNetworkRpm.htm" enctype="multipart/form-data" method="get" onSubmit="return doSubmit();">
以及
function doSubmit()
{……}
估计是js吧?

就将红色的代码改为:
;-----------------点登确认重启对话框-----------------
AdlibEnable("myadlib")
Exit

Func myadlib()
        If Not WinActive("Microsoft Internet Explorer","无线网络设置的更改将") Then WinActivate("Microsoft Internet Explorer","无线网络设置的更改将")
           If WinActive("Microsoft Internet Explorer","无线网络设置的更改将") Then
         Send("{ENTER}")
                ControlClick("Microsoft Internet Explorer", "OK", "","left",1)
   EndIf
EndFunc

但好像还是不能点中那个框:face (18):

maoying 发表于 2009-5-22 22:51:10

发现确实是js,参考了_IEAction 的第二个例子,解决了
据说是js把返回的值给拿去用了,没有返回,程序就一直假死

代码如下:
#include <IE.au3>
;-----------------点登录对话框----------------------
Run('C:\Program Files\Internet Explorer\IEXPLORE.EXE 192.168.1.1')
WinWait("Connect to 192.168.1.1","")
If Not WinActive("Connect to 192.168.1.1","") Then WinActivate("Connect to 192.168.1.1","")
WinWaitActive("Connect to 192.168.1.1","")
ControlClick("Connect to 192.168.1.1", "OK", "","left",1)        ;点OK按钮
;ControlSend("Connect to 192.168.1.1","","", "{ENTER}")                                ;这个也可以
;Send("{ENTER}")                                                                                                                                                                ;这个也可以
;------------------操作---------------------------
$oIE = _IEAttach ("TL-WR340G 54M无线宽带路由器","Title")
$oFrame = _IEFrameGetObjByName ($oIE, "bottomLeftFrame")
_IELinkClickByText ($oFrame, "无线参数")
$oFrame = _IEFrameGetObjByName ($oIE, "mainFrame")
$oForm = _IEFormGetCollection ($oFrame, 0)
_IEFormElementCheckboxSelect ($oForm, 2, "ap", 1, "byValue")      ;开启无线功能
;----------------------------------------------------------
$oQuery = _IEFormElementGetObjByName ($oForm, "Save")
;~ $oIE = _IEAction($oQuery ,"click")                                                                                    ;点"保存" _IELoadWait($oIE)
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction ($oQuery, "focus")
ControlSend($hwnd, "", "", "{Enter}")

; Wait for Alert window, then click on OK
WinWait("Microsoft Internet Explorer", "无线网络设置的更改将")
ControlClick("Microsoft Internet Explorer", "无线网络设置的更改将", "")
;-------------------询问关机------------------------------
$return = MsgBox(4,"shutdown","shutdown in 60 seconds", "60")
Select
        Case $return = -1
                Run(@ComSpec & " /c " & 'shutdown -f -s', "", @SW_HIDE)
        Case $return = 6
      Run(@ComSpec & " /c " & 'shutdown -f -s', "", @SW_HIDE)
    Case $return = 7
                Exit
EndSelect

发现有问题还是要靠自己解决啊!:face (36):

javarike 发表于 2009-6-6 16:55:34

很好,很好哈...

javarike 发表于 2009-6-6 16:55:41

很好,很好哈...

qq1244521 发表于 2009-6-8 22:51:39

不用点击呢 用 Y 或AIT加Y   看看
:face (1):

kn007 发表于 2009-6-8 23:21:17

不错啊,学习+学习楼主精神

kn007 发表于 2009-6-8 23:21:23

不错啊,学习+学习楼主精神
页: [1] 2 3
查看完整版本: 一个典型的弹出窗口问题(IE类函数处理完后,不能点击弹出窗口)