Jump to content

INet Advanced UDF


svennie
 Share

Recommended Posts

I have created a UDF to add more information about the download progress (with InetGet).

It creates an array with the following information:

$INetAdvInfo[0]=1 when downloading, 0 when not

$INetAdvInfo[1]=Url you are downloading from

$INetAdvInfo[2]=Local filename where downloading to

$INetAdvInfo[3]=Bytes read

$INetAdvInfo[4]=Bytes per second *

$INetAdvInfo[5]=Seconds until finished *

$INetAdvInfo[6]=Percent *

$INetAdvInfo[7]=Total size

* = calculated stuff that is not avaible with default InetGet

The function _INetAdvGo() is called by AdlibEnable to keep the information updated, dont call this function yourself!

_INetAdvGet:

;===============================================================================

;

; Function Name: _INetAdvGet()

; Description: Starts the downloading of a file in INetAdv mode.

; Parameter(s): $INetAdvUrl - URL of the file to download

; $INetAdvFile - Local filename to download to

; $INetAdvCache [optional] - 0 = (default) Get the file from local cache if available

; - 1 = Forces a reload from the remote site

; Requirement(s): AutoIt v3.1.1

; Return Value(s): On Success - Returns 1

; Creates (and keeps updating) an array with the following values:

; $INetAdvInfo[0]=1 when dowloading, 0 when not

; $INetAdvInfo[1]=Url you are downloading from

; $INetAdvInfo[2]=Local filename where downloading to

; $INetAdvInfo[3]=Bytes read

; $INetAdvInfo[4]=Bytes per second

; $INetAdvInfo[5]=Seconds until finished

; $INetAdvInfo[6]=Percent

; $INetAdvInfo[7]=Total size

; On Failure - Returns 0 and sets @error to 1

; Author(s): Svennie

;

;===============================================================================

_INetAdvAbort:

;===============================================================================

;

; Function Name: _INetAdvAbort()

; Description: Aborts a downloading file in INetAdv mode.

; Parameter(s): None

; Requirement(s): AutoIt v3.1.1

; Return Value(s): None

; Author(s): Svennie

;

;===============================================================================

You MUST start the download with _INetAdvGet to get the download information.

Change the location in the example to get the example work.

Thanks to Wb-FreeKill for the new example.

INetAdv.au3

INetAdv_Example.au3

Edited by svennie
Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF
Link to comment
Share on other sites

Nice..

The traytext didn't update correctly, so i edited a bit in your code, take a look..

#include <GuiConstants.au3>
#include <INetAdv.au3>
Opt("GUIOnEventMode",1)

Dim $URLInput,$Label_1,$Label_2,$Label_3,$Label_4,$Label_5,$Label_6,$Label_7,$Label_8,$StartBtn,$cleared = 0

GuiCreate("MyGUI", 392, 323,(@DesktopWidth-392)/2, (@DesktopHeight-323)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$URLInput = GUICtrlCreateInput("Input URL here",20,5,225,20)
$BrowseInput = GUICtrlCreateInput("",20,27,150,20,$ES_READONLY)
$BrowseBtn = GUICtrlCreateButton("Browse",175,27,70,20)
GuiCtrlCreateLabel("Active download:", 20, 50, 85, 20)
GuiCtrlCreateLabel("Source URL:", 20, 80, 85, 20)
GuiCtrlCreateLabel("Filename:", 20, 110, 85, 20)
GuiCtrlCreateLabel("Bytes Read:", 20, 140, 85, 20)
GuiCtrlCreateLabel("Bytes per Sec:", 20, 170, 85, 20)
GuiCtrlCreateLabel("Time Left:", 20, 200, 85, 20)
GuiCtrlCreateLabel("Percent:", 20, 230, 85, 20)
GuiCtrlCreateLabel("Total Size:", 20, 260, 85, 20)
$Label_1 = GuiCtrlCreateLabel("", 110, 50, 300, 20)
$Label_2 = GuiCtrlCreateLabel("", 110, 80, 300, 20)
$Label_3 = GuiCtrlCreateLabel("", 110, 110, 300, 20)
$Label_4 = GuiCtrlCreateLabel("", 110, 140, 300, 20)
$Label_5 = GuiCtrlCreateLabel("", 110, 170, 300, 20)
$Label_6 = GuiCtrlCreateLabel("", 110, 200, 300, 20)
$Label_7 = GuiCtrlCreateLabel("", 110, 230, 300, 20)
$Label_8 = GuiCtrlCreateLabel("", 110, 260, 300, 20)
$StartBtn = GUICtrlCreateButton("Start DL",145,290,100,25)

GUICtrlSetOnEvent($BrowseBtn,"_Browse")
GUICtrlSetOnEvent($StartBtn,"_StartDL")
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")

GuiSetState()
While 1
    $curInfo = GUIGetCursorInfo()   
    If $curInfo[2] = 1 AND $curInfo[4] = $URLInput AND $cleared = 0 Then
        GUICtrlSetData($URLInput,"")
        $cleared = 1
    EndIf

    If @InetGetActive Then
        GUICtrlSetData($Label_1,"Yes")
        GUICtrlSetData($Label_2,$INetAdvInfo[1])
        GUICtrlSetData($Label_3,$INetAdvInfo[2])
        GUICtrlSetData($Label_4,$INetAdvInfo[3] / 1024 & " Kb")
        GUICtrlSetData($Label_5,$INetAdvInfo[4] / 1024 & " Kb/s")
        GUICtrlSetData($Label_6,$INetAdvInfo[5] & " Seconds left")
        GUICtrlSetData($Label_7,$INetAdvInfo[6] & " %")
        GUICtrlSetData($Label_8,Round($INetAdvInfo[7] / 1024,0) & " Kb")
        Sleep(50)
    ElseIf Not @InetGetActive AND GUICtrlRead($Label_1) = "YES" Then
        GUICtrlSetData($Label_1,"No")
        GUICtrlSetData($Label_2,$INetAdvInfo[1])
        GUICtrlSetData($Label_3,$INetAdvInfo[2])
        GUICtrlSetData($Label_4,Round($INetAdvInfo[7] / 1024,0) & " Kb")
        GUICtrlSetData($Label_5,"0 Kb/s")
        GUICtrlSetData($Label_6,"0 Seconds left")
        GUICtrlSetData($Label_7,"100 %")
        GUICtrlSetData($Label_8,Round($INetAdvInfo[7] / 1024,0) & " Kb")
        Msgbox(0,"Download","Transfer Complete")
    EndIf   
WEnd

Func _Browse()
    $Save = FileSaveDialog( "Choose a name.", @DesktopDir, "All (*.*)" , 3)
    GUICtrlSetData($BrowseInput,$Save)
EndFunc 

Func _StartDL()
    _INetAdvGet (GUICtrlRead($URLInput), GUICtrlRead($BrowseInput), 1)
EndFunc 

Func _Exit()
    Exit
EndFunc
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

it looks like very great tool, but some things is incorrect.

First bytes per second: i did like this GUICtrlSetData($Label, $INetAdvInfo[4] / 1024) and if i downloaded something from one place(i can download there 400kb/s) it showed, that im downloading 100kb/s. Did i something wrong?

Second Seconds until finished: I downloaded file what was 400mb large and i downloaded 400kb/s, but this tool returned me 4000 seconds.Wtf?

Other things worked very well! Good job!

Link to comment
Share on other sites

Why don't you add the stuff for like the download speed into the UDF?

Like it is right now (in the example):

GUICtrlSetData($Label_1,"Yes")
        GUICtrlSetData($Label_2,$INetAdvInfo[1])
        GUICtrlSetData($Label_3,$INetAdvInfo[2])
        GUICtrlSetData($Label_4,$INetAdvInfo[3] / 1024 & " Kb")
        GUICtrlSetData($Label_5,$INetAdvInfo[4] / 1024 & " Kb/s")
        GUICtrlSetData($Label_6,$INetAdvInfo[5] & " Seconds left")
        GUICtrlSetData($Label_7,$INetAdvInfo[6] & " %")
        GUICtrlSetData($Label_8,Round($INetAdvInfo[7] / 1024,0) & " Kb")
        Sleep(50)

shouldn't all these calculations be in the UDF? Its not very good like this since the script0r still has to have the calculations in his script, not just in the UDF...

Hope you understand what i mean!

BTW, good job! I will take a look at this and maybe i'll use this for my download tool, would shrink it quite a bit!

Keep it up!

Felix N.

Link to comment
Share on other sites

Why don't you add the stuff for like the download speed into the UDF?

Like it is right now (in the example):

GUICtrlSetData($Label_1,"Yes")
        GUICtrlSetData($Label_2,$INetAdvInfo[1])
        GUICtrlSetData($Label_3,$INetAdvInfo[2])
        GUICtrlSetData($Label_4,$INetAdvInfo[3] / 1024 & " Kb")
        GUICtrlSetData($Label_5,$INetAdvInfo[4] / 1024 & " Kb/s")
        GUICtrlSetData($Label_6,$INetAdvInfo[5] & " Seconds left")
        GUICtrlSetData($Label_7,$INetAdvInfo[6] & " %")
        GUICtrlSetData($Label_8,Round($INetAdvInfo[7] / 1024,0) & " Kb")
        Sleep(50)

shouldn't all these calculations be in the UDF? Its not very good like this since the script0r still has to have the calculations in his script, not just in the UDF...

Hope you understand what i mean!

BTW, good job! I will take a look at this and maybe i'll use this for my download tool, would shrink it quite a bit!

Keep it up!

Felix N.

This is because it returns the exact value, like when it returns the download speed it returns it in bytes.

If you want to show the exact value you can use it directly, but if you just want to view it in kb you must calculate it yourself.

Edited by svennie
Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...