Jump to content
Sign in to follow this  
Kragen

Make InetGet Automaticly set filename

Recommended Posts

Kragen

I have searched for a while now, but I still can't make the InetGet function to set the filename as it is on the server.

Say i'm downloading www.Whatever.com/IMG0123.JPG from a server. I just want the downloaded file to be named "IMG0123.JPG", and not having to set it as a paramater every time I download a new file.

The script I have is this:

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>

#Region ### START Koda GUI section ### Form=
$Downloader = GUICreate("Lorentzen's Downloader", 481, 81, 256, 126)
$TargetURL = GUICtrlCreateInput("http://", 72, 16, 401, 21)
$L_URL = GUICtrlCreateLabel("Indsæt URL", 8, 16, 62, 17)
$B_Download = GUICtrlCreateButton("Download!", 368, 48, 105, 25, 0)
$DownloadProgress = GUICtrlCreateProgress(16, 48, 305, 25, $PBS_SMOOTH)
$Label1 = GUICtrlCreateLabel("Label1", 328, 48, 36, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $B_Download
            $URL = GUICtrlRead( $TargetURL )
            $TargetSize = InetGetSize( $URL )
            InetGet( $URL, "", -1, 1 )
            While @InetGetActive
                GUICtrlSetData ($DownloadProgress,Ceiling((@InetGetBytesRead/$TargetSize)*100))
            Wend
            GUICtrlSetData( $DownloadProgress, 0)
    EndSwitch
WEnd
it doesn't work. I simply don't get this.

This script is just for learning how to use progressbars and InetGet :)

Edited by Kragen

Share this post


Link to post
Share on other sites
Xand3r

I have searched for a while now, but I still can't make the InetGet function to set the filename as it is on the server.

Say i'm downloading www.Whatever.com/IMG0123.JPG from a server. I just want the downloaded file to be named "IMG0123.JPG", and not having to set it as a paramater every time I download a new file.

The script I have is this:

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>

#Region ### START Koda GUI section ### Form=
$Downloader = GUICreate("Lorentzen's Downloader", 481, 81, 256, 126)
$TargetURL = GUICtrlCreateInput("http://", 72, 16, 401, 21)
$L_URL = GUICtrlCreateLabel("Indsæt URL", 8, 16, 62, 17)
$B_Download = GUICtrlCreateButton("Download!", 368, 48, 105, 25, 0)
$DownloadProgress = GUICtrlCreateProgress(16, 48, 305, 25, $PBS_SMOOTH)
$Label1 = GUICtrlCreateLabel("Label1", 328, 48, 36, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $B_Download
            $URL = GUICtrlRead( $TargetURL )
            $TargetSize = InetGetSize( $URL )
            InetGet( $URL, "", -1, 1 )
            While @InetGetActive
                GUICtrlSetData ($DownloadProgress,Ceiling((@InetGetBytesRead/$TargetSize)*100))
            Wend
            GUICtrlSetData( $DownloadProgress, 0)
    EndSwitch
WEnd

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

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  

×