2011-04-28 53 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

回答