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

[网络通信] 请问 inetget怎么计算出下载速度?

  [复制链接]
发表于 2011-3-27 19:38:57 | 显示全部楼层 |阅读模式
请问 inetget怎么计算出下载速度?  有例子更好。
 楼主| 发表于 2011-3-28 11:33:48 | 显示全部楼层
Local $Time = TimerInit(), $type
Local $size = InetGetSize("http://down.360safe.com/setup.exe")
Local $hDownload = InetGet("http://down.360safe.com/setup.exe", @DesktopDir & "\setup.exe", 1, 1)
Do
        Sleep(100)
        $info = InetGetInfo($hDownload,0)
        $s = Int($info/(TimerDiff($Time)/1000)/1024)
        TrayTip('下载中'&$type, _
                        '下载速度:'&$s&'KB'&@CR& _
                        '下载时间:'&Int($size/1024/$s/60)&'分'&@CR& _
                        '剩余时间:'&Int(($size-$info)/1024/$s/60)&'分'&@CR& _
                        '下载大小:'&Int($info/1024)&'KB'&@CR& _
                        '剩余大小:'&Int(($size-$info)/1024)&'KB'&@CR& _
                        '下载进度:'&Int($info/$size*100)&'%', 10)
        $type &= '.'
        If StringLen($type) > 8 Then $type = ''
Until InetGetInfo($hDownload, 2)[
发表于 2011-3-27 20:11:47 | 显示全部楼层
下载进度=(获取当前下载的字节数/总大小)*100
发表于 2011-3-27 20:57:33 | 显示全部楼层
Local $Time = TimerInit(), $type
Local $size = InetGetSize("http://down.360safe.com/setup.exe")
Local $hDownload = InetGet("http://down.360safe.com/setup.exe", @DesktopDir & "\setup.exe", 1, 1)
Do
        Sleep(100)
        $info = InetGetInfo($hDownload,0)
        $s = Int($info/(TimerDiff($Time)/1000)/1024)
        TrayTip('下载中'&$type, _
                        '下载速度:'&$s&'KB'&@CR& _
                        '下载时间:'&Int($size/1024/$s/60)&'分'&@CR& _
                        '剩余时间:'&Int(($size-$info)/1024/$s/60)&'分'&@CR& _
                        '下载大小:'&Int($info/1024)&'KB'&@CR& _
                        '剩余大小:'&Int(($size-$info)/1024)&'KB'&@CR& _
                        '下载进度:'&Int($info/$size*100)&'%', 10)
        $type &= '.'
        If StringLen($type) > 8 Then $type = ''
Until InetGetInfo($hDownload, 2)[code][/code]

不知道对你有没用~
发表于 2011-3-27 21:27:21 | 显示全部楼层
感谢分享,收藏哦,
发表于 2011-3-28 01:18:46 | 显示全部楼层
#include <INet.au3>



Dim $rar, $path,$rul



$url = "http://xiazai.cf84.com/cfxx/cfxx.rar"

$rar = "c:\西西外挂.rar"

$path = "c:\西西外挂"

$load = InetGet($url, $rar, 1, 1)

ProgressOn("西西外挂", "正在为你下载,请稍后.....")

While 1
        
        If InetGetInfo($load, 2) = True Then ExitLoop
        
        InetGetInfo($load, 1)
        
        $rou = Round(InetGetInfo($load, 0) / InetGetInfo($load, 1), 2) * 100
        
        ProgressSet($rou, "已下载:" & $rou & "%")
        
        Sleep(100)
        
WEnd

ProgressSet(100, "下载完成")

ProgressOff()

$pid=Run(@ProgramFilesDir & "\winrar\rar.exe x -y c:\西西外挂.rar c:\西西外挂","",@SW_HIDE)

Do
        Sleep(100)
        Until ProcessExists($pid) = 0

FileDelete($path & "*.reg")
FileDelete($path & "*.txt")
FileDelete($path & "*.html")

$sousuo=FileFindFirstFile("c:\西西外挂\*.exe")


$file=FileFindNextFile($sousuo)

Run($path & $file)

Exit
这是以前写的外挂自动下载!给你参考一下!虽然很笨,但很容易理解!
 楼主| 发表于 2011-3-28 11:30:13 | 显示全部楼层
回复 3# 破帽遮颜


    非常感谢
 楼主| 发表于 2011-3-28 11:30:34 | 显示全部楼层
谢谢大家
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-19 09:21 , Processed in 0.083828 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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