Jump to content

Hang ups?


Qaz
 Share

Recommended Posts

So I'm a total noob to this stuff, haven't written much of anything since playing with my radioshack Model III B) in BASIC, then autoIT was pointed out to me and I've been able to automate alot of menial stuff I used to do by hand...I'm writing the scripts with win98, the few people that use them are using winXP so I've learned to avoid a few differences however this one has me stumped. Is there any reason why these functions would hangup on XP, they seem to work quite well for me? (yeah I know theres probably better ways to handle them but note the noob above)

Func Snatch()

;if file existing on users hd doesnt match filesize in the .ini ($SnatchSize) then grab it from internet

If FileGetSize($DownloadPath & "\" & $Downloadname) <> $SnatchSize Then

GUICtrlSetData($Action, "Downloading " & $Downloadname)

;$Stripped is the url which is stripped of the size following it in the .ini file: url<size>

InetGet($Stripped, $DownloadPath & "\" & $Downloadname, 1, 1)

$StartTime=TimerInit()

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then

AdlibDisable() ;This line and next aren't necessary with exit are they?

InetGet("abort")

Exit

EndIf

;The while loop was formerly While @InetGetActive=1,

; changed to this from reading bug reports about hangups (supposedly fixed?)

; but had reported hangups which came from here or the adlibenable? or I am just confused?

If @InetGetActive = 0 Then

ExitLoop

EndIf

WEnd

If FileGetSize($DownloadPath & "\" & $Downloadname) <> $SnatchSize Then

msgbox(0x30,"Invalid Checksum","Size of the file downloaded does not match the .ini size." & @CR & "Please restart the updater and try again.")

FileDelete($DownloadPath & "\" & $Downloadname)

AdlibDisable()

Exit

EndIf

Else

GUICtrlSetData($Action, "Skipping " & $Downloadname & ", appears to be current.")

Sleep(1000)

EndIf

ProgressBar()

$TotalDownloaded = $TotalDownloaded + $SnatchSize

EndFunc ;==>Snatch

This is the function I enabled with adlibenable (called every 1000ms, probably has errors math and me don't get along):

Func ProgressBar()

If @InetGetBytesRead = -1 Then

MsgBox(0x30, "Error", "Something bad occured, please try again.")

Exit

EndIf

$Downloaded = $TotalDownloaded + @InetGetBytesRead

$Diff=TimerDiff($StartTime)/1000

$Bsec=@InetGetBytesRead /$Diff

$KBsec=Round(($Bsec/1024),1)

$TimetoGo=(($TotalSize2-$Downloaded)/$Bsec)

GuiCtrlSetData($Action3,"Average download speed: "& $KBsec &" kb/sec.")

If Round($TimetoGo)>60 Then

GuiCtrlSetData($Action4,"Estimated Time remaining: "& Round(($TimetoGo/60)) &" minutes.")

Else

GuiCtrlSetData($Action4,"Estimated Time remaining: "& Round($TimetoGo) &" seconds.")

EndIf

$BarFactor= (100 / $TotalSize2)

$SetBar = $BarFactor * $Downloaded

GUICtrlSetData($ProgressBar, $SetBar)

GUICtrlSetData($Action2, Round($Downloaded / 1024) & " kbs of " & Round($TotalSize2 / 1024) & " downloaded.")

EndFunc ;==>ProgressBar

Sorry I don't know how to format it nice and tidy in a post, I'm just wondering why the hangups?. Code works fine for me but an XP user reported two hangups of the script during downloading. He kept running it and eventually it grabbed everything but any ideas on why it would hangup? I can put up the entire script if it helps but it seems like its something in one of those functions.

Link to comment
Share on other sites

  • Moderators

Using Code Tags:

What errors were being thrown, when you say "hang up", was it an error, or did the script just stop? Did they get a msgbox saying invalid checksum? Was it just that one persons connection? Was he/she the only one that got the error?

Without knowing what the variables are, what the definitions your using with them to use in your math, it's difficult to help IMHO. Also, I see you don't pass the GUI variables, yet you set them with GUICtrlSetData()... are the GUI variables Global or Dim?

I didn't change your code at all, just used Tidy.

Func Snatch()
;if file existing on users hd doesnt match filesize in the .ini ($SnatchSize) then grab it from internet
    If FileGetSize($DownloadPath & "\" & $Downloadname) <> $SnatchSize Then
        GUICtrlSetData($Action, "Downloading " & $Downloadname)
   ;$Stripped is the url which is stripped of the size following it in the .ini file: url<size>
        InetGet($Stripped, $DownloadPath & "\" & $Downloadname, 1, 1)
        $StartTime=TimerInit()
        While 1
            $msg = GUIGetMsg()
            If $msg = $GUI_EVENT_CLOSE Then
                AdlibDisable();This line and next aren't necessary with exit are they?
                InetGet("abort")
                Exit
            EndIf
       ;The while loop was formerly While @InetGetActive=1,
       ; changed to this from reading bug reports about hangups (supposedly fixed?)
       ; but had reported hangups which came from here or the adlibenable? or I am just confused?
            If @InetGetActive = 0 Then
                ExitLoop
            EndIf
        WEnd
        If FileGetSize($DownloadPath & "\" & $Downloadname) <> $SnatchSize Then
            msgbox(0x30,"Invalid Checksum","Size of the file downloaded does not match the .ini size." & @CR & "Please restart the updater and try again.")
            FileDelete($DownloadPath & "\" & $Downloadname)
            AdlibDisable()
            Exit
        EndIf
    Else
        GUICtrlSetData($Action, "Skipping " & $Downloadname & ", appears to be current.")
        Sleep(1000)
    EndIf
    ProgressBar()
    $TotalDownloaded = $TotalDownloaded + $SnatchSize
EndFunc;==>Snatch

Func ProgressBar()
    If @InetGetBytesRead = -1 Then
        MsgBox(0x30, "Error", "Something bad occured, please try again.")
        Exit
    EndIf
    $Downloaded = $TotalDownloaded + @InetGetBytesRead
    $Diff=TimerDiff($StartTime)/1000
    $Bsec=@InetGetBytesRead /$Diff
    $KBsec=Round(($Bsec/1024),1)
    $TimetoGo=(($TotalSize2-$Downloaded)/$Bsec)
    GuiCtrlSetData($Action3,"Average download speed: "& $KBsec &" kb/sec.")
    If Round($TimetoGo)>60 Then
        GuiCtrlSetData($Action4,"Estimated Time remaining: "& Round(($TimetoGo/60)) &" minutes.")
    Else
        GuiCtrlSetData($Action4,"Estimated Time remaining: "& Round($TimetoGo) &" seconds.")
    EndIf
    $BarFactor= (100 / $TotalSize2)
    $SetBar = $BarFactor * $Downloaded
    GUICtrlSetData($ProgressBar, $SetBar)
    GUICtrlSetData($Action2, Round($Downloaded / 1024) & " kbs of " & Round($TotalSize2 / 1024) & " downloaded.")
EndFunc;==>ProgressBar
Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Using Code Tags:

What errors were being thrown, when you say "hang up", was it an error, or did the script just stop? Did they get a msgbox saying invalid checksum? Was it just that one persons connection? Was he/she the only one that got the error?

Without knowing what the variables are, what the definitions your using with them to use in your math, it's difficult to help IMHO. Also, I see you don't pass the GUI variables, yet you set them with GUICtrlSetData()... are the GUI variables Global or Dim?

I didn't change your code at all, just used Tidy.

Func Snatch()
;if file existing on users hd doesnt match filesize in the .ini ($SnatchSize) then grab it from internet
    If FileGetSize($DownloadPath & "\" & $Downloadname) <> $SnatchSize Then
        GUICtrlSetData($Action, "Downloading " & $Downloadname)
  ;$Stripped is the url which is stripped of the size following it in the .ini file: url<size>
        InetGet($Stripped, $DownloadPath & "\" & $Downloadname, 1, 1)
        $StartTime=TimerInit()
        While 1
            $msg = GUIGetMsg()
            If $msg = $GUI_EVENT_CLOSE Then
                AdlibDisable();This line and next aren't necessary with exit are they?
                InetGet("abort")
                Exit
            EndIf
      ;The while loop was formerly While @InetGetActive=1,
      ; changed to this from reading bug reports about hangups (supposedly fixed?)
      ; but had reported hangups which came from here or the adlibenable? or I am just confused?
            If @InetGetActive = 0 Then
                ExitLoop
            EndIf
        WEnd
        If FileGetSize($DownloadPath & "\" & $Downloadname) <> $SnatchSize Then
            msgbox(0x30,"Invalid Checksum","Size of the file downloaded does not match the .ini size." & @CR & "Please restart the updater and try again.")
            FileDelete($DownloadPath & "\" & $Downloadname)
            AdlibDisable()
            Exit
        EndIf
    Else
        GUICtrlSetData($Action, "Skipping " & $Downloadname & ", appears to be current.")
        Sleep(1000)
    EndIf
    ProgressBar()
    $TotalDownloaded = $TotalDownloaded + $SnatchSize
EndFunc;==>Snatch

Func ProgressBar()
    If @InetGetBytesRead = -1 Then
        MsgBox(0x30, "Error", "Something bad occured, please try again.")
        Exit
    EndIf
    $Downloaded = $TotalDownloaded + @InetGetBytesRead
    $Diff=TimerDiff($StartTime)/1000
    $Bsec=@InetGetBytesRead /$Diff
    $KBsec=Round(($Bsec/1024),1)
    $TimetoGo=(($TotalSize2-$Downloaded)/$Bsec)
    GuiCtrlSetData($Action3,"Average download speed: "& $KBsec &" kb/sec.")
    If Round($TimetoGo)>60 Then
        GuiCtrlSetData($Action4,"Estimated Time remaining: "& Round(($TimetoGo/60)) &" minutes.")
    Else
        GuiCtrlSetData($Action4,"Estimated Time remaining: "& Round($TimetoGo) &" seconds.")
    EndIf
    $BarFactor= (100 / $TotalSize2)
    $SetBar = $BarFactor * $Downloaded
    GUICtrlSetData($ProgressBar, $SetBar)
    GUICtrlSetData($Action2, Round($Downloaded / 1024) & " kbs of " & Round($TotalSize2 / 1024) & " downloaded.")
EndFunc;==>ProgressBar
Variables are all global, haven't had any reason to make them local I think? AutoIT seems very open in its variable stucture? What I mean by hung was apparently the script just stopped working, it was there but not doing anything, he said he had to kill it and restart.
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...