找回密码
 加入
搜索
查看: 2810|回复: 7

求助.自动下载安装的AU3程序.

  [复制链接]
发表于 2009-3-2 11:34:57 | 显示全部楼层 |阅读模式
哪位高人会写"自动从远程HTTP下载文件,并且带进度条显示,下载完成后自动运行该文件后退出,的小程序,
请帮帮忙,谢了!
发表于 2009-3-2 13:44:43 | 显示全部楼层
可以参考Au3自带的下载更新程序AutoUpdateIt.au3呀。

有进度条,检测版本号等,功能很齐全。

 楼主| 发表于 2009-3-5 05:44:57 | 显示全部楼层

我已经找到了,谢谢!

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
Dim $under, $upon, $per, $res, $filesize, $Inetget, $setup;定义变量
$Form1 = GUICreate("Form1", 200, 8, @DesktopWidth/2-100, 1, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW + $WS_EX_LAYERED) ;创建窗体
GUISetBkColor(0xABCDEF)
_API_SetLayeredWindowAttributes($Form1, 0xABCDEF)
ToolTip("■■■■■软件正在安装中,请稍后■■■■", 400, 200)
$Inetget = "http://192.168.0.244/download/speak/yy.exe";;;
$setup = "d:\yy.exe"
$under = InetGetSize($Inetget) ;获取目标文件大小
InetGet($Inetget, $setup, 1, 1) ;下载目标文件
GUISetState()

While @InetGetActive ;判定循环条件
        Sleep(100)
        $upon = @InetGetBytesRead ;获取已下载大小
        $per = $upon / $under * 100 ;计算比值
        $res = StringLeft($per, 3) ;计算百分值
        GUICtrlSetData(-1, $res) ;下载进度的值
WEnd
GUISetState (@SW_HIDE,$Form1)
Run($setup)
Func _API_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $isColorRef = False)

Local Const $AC_SRC_ALPHA = 1
Local Const $ULW_ALPHA = 2
Local Const $LWA_ALPHA = 0x2
Local Const $LWA_COLORKEY = 0x1
If Not $isColorRef Then
   $i_transcolor = Hex(String($i_transcolor), 6)
   $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
EndIf
Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $LWA_COLORKEY + $LWA_ALPHA)
Select
   Case @error
    Return SetError(@error, 0, 0)
   Case $Ret[0] = 0
    Return SetError(4, 0, 0)
   Case Else
    Return 1
EndSelect
EndFunc   ;==>_API_SetLayeredWindowAttributes
发表于 2010-1-4 19:53:00 | 显示全部楼层
快一年了...怎没有人顶帖呀.
发表于 2010-1-22 20:55:35 | 显示全部楼层
怎没有人顶帖呀. 帮你顶顶
发表于 2012-2-22 10:12:03 | 显示全部楼层
出错了。运行有好几个错误。
发表于 2012-3-14 00:53:43 | 显示全部楼层
好多错误呀!
发表于 2015-12-30 09:22:00 | 显示全部楼层
太好了,谢谢楼主分享
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-29 00:21 , Processed in 0.099843 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表