码迷,mamicode.com
首页 > 其他好文 > 详细

AutoIT 实现Firefox下载

时间:2014-09-16 15:43:50      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:blog   io   ar   for   文件   div   sp   cti   代码   

Firefox下载的完整代码:

Func IsVisible($handle)
	;WinGetState:  2 = Window is visible
	If BitAND(WinGetState($handle), 2) Then
		Return 1
	Else
		Return 0
	EndIf
EndFunc   ;==>IsVisible

;firefox下载
Func _DownloadFile()
    AutoItSetOption("WinTitleMatchMode", 2);
    WinWaitActive("正在打开 test.zip","", 15);
	
	If WinActivate("正在打开 test.zip", "") Then
		Local $handle = WinGetHandle("正在打开 test.zip")

		Send("!s")
		Send("{enter}")
		WinWaitActive("输入要保存的文件名…","")
		If(WinActivate("输入要保存的文件名…","")) Then
			ControlSetText("", "", "[CLASS:Edit; INSTANCE:1]", "D:\auto.zip")
			ControlClick("", "","[CLASS:Button; TEXT:保存(&S)]")
			
			;Returns an array of matching window titles and handles.
			Local $var = WinList()
			For $i = 1 To $var[0][0]
			; Only display visble windows that have a title
				If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
					;MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
					If $var[$i][0]=="输入要保存的文件名…" And $var[$i][1] <> $handle Then
						;MsgBox(64,"hello","have sub Window!!!")
						Send("!y")
					EndIf
				EndIf
			Next
		EndIf
	else
		Return False
	EndIf
	Exit
   
EndFunc
_DownloadFile()

  

AutoIT 实现Firefox下载

标签:blog   io   ar   for   文件   div   sp   cti   代码   

原文地址:http://www.cnblogs.com/yangxia-test/p/3974797.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!