2011-04-28 126 views
0

我已经为IE的文件下载写了一个脚本。 如果焦点在下载框上,它工作正常。所以明确我试图把重点放在下载窗口有时它有效,有时不。 早些时候我试图通过直接使用窗口名称,但它不工作,所以我已经尝试使用Windows,但相同的结果当对话框没有焦点时,无法点击保存按钮

另一种情况是:点击IE页面中的下载链接,看到对话框,打开实例的铬或歌剧浏览器。并运行失败的脚本。我不知道为什么会发生。 再次如果它运行在远程destop上,并且我将最小化或关闭连接,它会随机失败。

任何人都可以告诉出了什么问题? _any帮助将被罚款_

我在这里附上的脚本示例:

AutoItSetOption("WinTitleMatchMode","2") ; 
; wait Until dialog box appears and timemout of 10 seconds. 
$wait = WinWait("Download","",30) 
$title = WinGetTitle("Download") 
$handle = WinGetHandle($title) 
WinActivate($handle) 
If $wait =0 Then 
Exit 
EndIf 
If (StringCompare($CmdLine[2],"Save",0) = 0) Then 
$wait = WinWaitActive($handle,"",10) 
If $wait =0 Then 
Exit 
EndIf 
ControlClick($handle,"","Button2") 
$wait = WinWait("Save","",5) 
If $wait =0 Then 
Exit 
EndIf 
$title = WinGetTitle("Save") 
$handle = WinGetHandle($title) 
if($CmdLine[0] = 2) Then 
$wait = WinWaitActive($handle,"",5) 
If $wait =0 Then 
Exit 
EndIf 
ControlClick($handle,"","Button2") 
Else 
;Set path and save file 
$wait = WinWaitActive($handle,"",10) 
If $wait =0 Then 
Exit 
EndIf 
ControlSetText($handle,"","Edit1",$CmdLine[3]) 
ControlClick($handle,"","Button2") 
Exit 
EndIf 
EndIf 
+0

我看到一个突出的问题,WinActivate()不接受窗口句柄作为参数,它期望窗口的标题。 – JohnForDummies 2011-04-29 21:29:47

+0

好吧,我试过标题也没有工作,所以我尝试使用句柄。 – 2011-05-04 04:57:09

回答