Sign in to follow this  
Followers 0
CyberAssassin

wGet

7 posts in this topic

Hi Ive made a simple gui for wGet. So far the whole thing works but Im trying to incorporate a status bar into it. Based upon the size of the file on the server and then it would compare that to the size of the downloaded file. Any Ideas? Here is what I have so far.

#include<GUIconstants.au3>
#include<Process.au3>

GUICreate("Wget",300,75,-1,-1,-1)
GUISetState()

$input = GUICtrlCreateInput("Enter URL here", 1, 1, 298, 45)
$get = GUICtrlCreateButton("Get!", 0, 50, 300, 25)
$progress = GUICtrlCreateProgress(2, 46, 298, 5, $PBS_SMOOTH)

While 1
    Sleep(100)
    $gMsg = GUIGetMsg()
    Switch $gMsg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $get
        _get()
    EndSwitch
WEnd

Func _get()
    $input = GUICtrlRead($input)
    $filesize = InetGetSize($input)
    Run("wget.exe " & $input)
EndFunc

Share this post


Link to post
Share on other sites



wget has a --progress option, you could parse the console output and make your progress indicator using the stdio functions.

Note that they have dramatically changed with the new beta...Ensure you download / program against that unless you want to do it twice.


Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

Why not just use INetGet?

o.0

Share this post


Link to post
Share on other sites

Why not just use INetGet?

o.0

Compare featuresets of the two methodologies, grasshopper.

1 person likes this

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

hi

the progress bar is rather jumpy on my machine , but it works

; -----------------------------------------------------------------------------------------------

#include <GUIConstants.au3>
#include <String.au3>
#include <GUIStatusBar.au3>

#Region ### START Koda GUI section ### Form=

$GUI = GUICreate("", 612, 387, 193, 115)
$edit_input = GUICtrlCreateInput("", 16, 48, 449, 21)
$btn_download = GUICtrlCreateButton("Download", 480, 48, 75, 25, 0)
$progress = GUICtrlCreateProgress(16, 120, 446, 17)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        
        ;; do a single Download ..
        Case $btn_download
            
            GUICtrlSetState($btn_download, $GUI_DISABLE)
            
            $dwnlink = GUICtrlRead($edit_input)

            _download_this_url($dwnlink, 0) ; unattended == 0??

            ;; close
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd



;
Func _download_this_url($url, $unattended)
    
    GUICtrlSetData($progress, 0) ;; progress bar

    $c = "wget.exe " & ' "' & $url & '"'

    $pid = Run($c, @ScriptDir, @SW_HIDE, $STDERR_CHILD)

    ProcessSetPriority($pid, 0) ;; lowest

    $streamcounter = 0

    ;; thsi is rather jumpy on my machine

    While ProcessExists($pid)
        If 1 <= $streamcounter Then
            $readstream = StderrRead($pid);,0,true)
            ;           ClipPut($readstream);
            ;            MsgBox(0, "%", $readstream);
            ;; read %
            $tmp = _StringBetween($readstream, ".....", '%')
            If @error <> 1 Then
                
                $percent = StringReplace($tmp[0], ".", "");
                $percent = StringStripWS($percent, "7");
                
                GUICtrlSetData($progress, $percent) ;; progress bar
                ;            MsgBox(0, "%", $percent);

            EndIf ;; found duration ??
            $streamcounter = 0
        EndIf
        $streamcounter = $streamcounter + 1
        
    WEnd
    
    
    GUICtrlSetData($progress, 100) ;; progress bar

EndFunc   ;==>_download_this_url

Share this post


Link to post
Share on other sites

Flyingboz is right. InetGet commands are unusable on PC's with no Internet Explorer Components (such as European editions of MS-Windows). However, using output from Console proves to be more versatile and usable.

Regards


----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

MKISH,

We discourage necro-posting in threads after more than a year or so - tha language has changed so much it makes little sense to reopen them. :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0