#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ie.au3>
$oIE = ObjCreate("Shell.Explorer.1")
#Region ### START Koda GUI section ### Form=
$GUIMain = GUICreate("GUIMain", 300, 200, 0, 0)
GUICtrlCreateObj($oIE, 0, -0, 200, 100)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$EventObject=ObjEvent($oIE,"IEEvent_","DWebBrowserEvents")
$URL = "http://pzz.cn/a.html"
$oIE.Navigate( $URL )
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func IEEvent_NewWindow($ppDisp,$Cancel)
Local $o_Shell = ObjCreate("Shell.Application")
Local $o_ShellWindows = $o_Shell.Windows(); collection of all ShellWindows (IE and File Explorer)
For $i = $o_ShellWindows.Count-1 To 0 Step -1
If $o_ShellWindows.item($i).LocationURL==$ppDisp Then
$o_ShellWindows.item($i).quit()
EndIf
Next
$oIE.Navigate( $ppDisp )
EndFunc
当点击UI网页里的"下载安装文件到电脑"直接在UI中显示一个进度条直接进行下载,而不是弹出IE的对话框中的下载呢?
点击下载时,类似以下程序这样。#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("测试", 623, 442, 192, 124)
$Progress1 = GUICtrlCreateProgress(72, 96, 393, 65)
$Button1 = GUICtrlCreateButton("", 104, 216, 305, 97)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$url = "http://pzz.cn/soft/g64.exe"
$get = InetGet($url, @ScriptDir & "\g64.exe", 1, 1)
$size = Int(InetGetSize($url) / 1024)
AdlibRegister("Down")
EndSwitch
WEnd
Func Down()
$newsize = InetGetInfo($get)
$pro = Int($newsize[0] / 1024) / $size
GUICtrlSetData($Progress1, $pro * 100)
GUICtrlSetData($Button1, "已下载 " & Int($pro * 100) & "%")
EndFunc ;==>Down
|