Not able to click the Save button when dialog is not having the focus
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 do开发者_JS百科wnload 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
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/
精彩评论