Jump to content

Make InetGet Automaticly set filename


Kragen
 Share

Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

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