0

我为 IE 编写了一个文件下载脚本。如果焦点在下载框上,它工作正常。如此明确地,我试图将注意力集中在下载窗口上,有时它有效,有时无效。早些时候我尝试直接使用窗口名称但它不起作用所以我尝试使用窗口但结果相同

还有一种场景是:点击IE页面的下载链接,看到对话框,打开chrome或opera浏览器的实例。并运行它失败的脚本。我不确定它为什么会发生。同样,如果它在远程桌面上运行并且我最小化或关闭连接,它会随机失败。

任何人都可以说出出了什么问题吗?_任何帮助都会好的_

我在这里附上脚本示例:

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
4

1 回答 1

3

当您在 IE 中处理页面时,我建议您使用 udf IE.au3。此 UDF 默认用于与 IE 集成。

您拥有的最佳资源是 Autoit 论坛。那里的人很聪明,对解决问题也很了解。链接到正在处理下载的人:http ://www.autoitscript.com/forum/topic/90502-solved-handling-the-ie-download-file-dialog/

于 2011-06-15T15:01:19.250 回答