当对话框没有焦点时无法单击“保存”按钮

发布于 2024-11-04 00:18:25 字数 1148 浏览 4 评论 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

I have written a script for file download for IE.
It works fine if the focus is on the download box. So explicitly I am trying to get the focus on the download window Sometimes it works , sometimes doesn't.
Earlier I tried doing by using the window names directly but it was not working so i have tried using windows but same results

One more scenario is : click on the download link in IE page, see the dialog box, open instance of chrome or opera browser. And run the script it fails. I am not sure why its happening.
Again if it runs on the remote destop and i am minimize or close the connection it fails randomly.

Can any one tell what went wrong?
_Any help will be fine _

I am attaching the script example here:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十年不长 2024-11-11 00:18:25

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

您拥有的最好的资源是 Autoit 论坛。那里的人非常聪明,懂得很多解决问题的方法。链接到正在处理下载的人员:http://www.autoitscript.com/forum/topic/90502-solved-handling-the-ie-download-file-dialog/

When you are working with a page in IE I would recommend using the udf IE.au3. This UDF comes default for integrating with IE.

The best resource you have are Autoit forums. The people there are very smart and know a lot about solving . Link to someone who was working with downloads: http://www.autoitscript.com/forum/topic/90502-solved-handling-the-ie-download-file-dialog/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文