我为 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