Sign in to follow this  
Followers 0
Buffo

Variable will not take any values

6 posts in this topic

I need some help, please :geek:

Here a test script that will download a file and in the meanwhile a progressbar will be displayed.

Dim $i_Size, $i_Progress, $gui, $prg

$i_Size = InetGetSize("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3.2.0.1-setup.exe")
If $i_Size = 0 Then
    MsgBox(32, "Problem occcured", "Download cancelled")
    Exit
EndIf   
INetGet("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3.2.0.1-setup.exe", @ScriptDir & "\Test.exe", 1, 1)
$gui = GuiCreate("Download progress", 400, 40)
$prg = GUICtrlCreateProgress(4, 4, 392, 24)
GUISetState(@SW_SHOW)
While $i_Progress <> 100  
    $i_CurrSize = FileGetSize(@ScriptDir & "\test.exe") 
    $i_Progess = Round($i_CurrSize * 100 / $i_Size)
    ConsoleWrite($i_Progress & @CRLF)
    GuiCtrlSetData($prg, $i_Progress)
    Sleep(1000)
WEnd
MsgBox(32, "Download successful", "Press OK to quit")

The $i_Progress between While...WEnd never gets a Value even if you try to overwrite $i_Progess = Round($i_CurrSize * 100 / $i_Size) with $i_Progress = "This is my value" it will not take it.

What is wrong here. I don't know :ph34r:

Am I too tired to find out or mybe it's a AutoIt-Bug?

BTW: My version is currently AutotIt 3.2.0.1

Thx for help in advance :lmao:

Regards,

Buffo

Share this post


Link to post
Share on other sites



Dont know about this, though maybe you could use a while @InetGetBytesRead instead.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

Hi,

try this:

$i_Size = InetGetSize("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3.2.0.1-setup.exe")
MsgBox(0,"", $i_Size)

If $i_Size = 0 Then
    MsgBox(32, "Problem occcured", "Download cancelled")
    Exit
EndIf    

INetGet("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3.2.0.1-setup.exe", @ScriptDir & "\Test.exe", 1, 1)
$gui = GuiCreate("Download progress", 400, 40)
$prg = GUICtrlCreateProgress(4, 4, 392, 24)
GUISetState(@SW_SHOW)

While @InetGetActive
    GuiCtrlSetData($prg, (@InetGetBytesRead * 100 / $i_Size))
    Sleep(100)
WEnd
MsgBox(32, "Download successful", "Press OK to quit")

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I suspect the problem is with the fact that your URL is not pointing directly to the file, but rather to script getfile.pl which is passed the parameter "autoit3/autoit-v3.2.0.1-setup.exe". There is no "size" to what your URL is pointing to!

Try this URL instead:

http://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.2.1.9-beta-setup.exe

J

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thx a lot for the fast help :ph34r:

First of all I have to say that I never did anything with internet with Autoit before. So I didn't know that there are constants to use. I should have read the help file more exact :lmao:

@th.meger: That's work great. It's exactly what I need but I din't search the help file so I wanted to tinker my own solution :geek:

But why I cannot set the $i_Progress variable to any value will stay my question? I would be lucky if anybody has the answer :)

Regards,

Buffo

Edited by Buffo

Share this post


Link to post
Share on other sites

Hi,

here is a solution a bit more like you tried :

HotKeySet("1", "_end")

$i_Size = InetGetSize("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3.2.0.1-setup.exe")
MsgBox(0, "", $i_Size)

If $i_Size = 0 Then
    MsgBox(32, "Problem occcured", "Download cancelled")
    Exit
EndIf

InetGet("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3.2.0.1-setup.exe", @ScriptDir & "\Test.exe", 1, 1)

$gui = GUICreate("Download progress", 400, 40)
$prg = GUICtrlCreateProgress(4, 4, 392, 24)

GUISetState(@SW_SHOW)

While GUICtrlRead($prg) <> 100
    GUICtrlSetData($prg, Round(FileGetSize(@ScriptDir & "\test.exe") * 100 / $i_Size))
    Sleep(10)
WEnd
MsgBox(32, "Download successful", "Press OK to quit")

Func _end()
    Exit(0)
EndFunc

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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