Sign in to follow this  
Followers 0
gnosis3d

Script crashes after Progress Bar

10 posts in this topic

#1 ·  Posted (edited)

I can't for the life of me figure out what causes this. I have a progress bar come up on the GUI after particular button presses. If the user clicks a button, changes tabs, or types inside any input windows, the program crashes (about 80% of the time).

$prog = _ProgressOn($progress,$main,$sub,$partnum,"",16,248,1)
            InetGet("ftp://" & $FTPaccess & $FTPserver & $NTKSartworkDir & $partnum & "/" & $partnum & ".pdf", $inprogressdir & $partnum & ".pdf",1,1)
        ; need to divide by 1048576 also, variables that don't change should be outside loop
            $FileSize = $netDnFileSize/1048576
            $netfiledownload = round($netDnFileSize/1048576, 1)
            Do
                $filedownload = round(@InetGetBytesRead/1048576, 1)
                $Percent = Round(($filedownload/$FileSize)*100);need to mutliply by 10 to get percentage
                _ProgressSet($prog, $Percent,"Copied " & $filedownload & " MB of " & $netfiledownload & " MB")
            ;TrayTip("Downloading...", "Downloaded = " & $filedownload & " Mb", 10, 16)
                Sleep(1000)
            Until FileGetSize($inprogressdir & $partnum & ".pdf") = $netDnFileSize
            _ProgressOff($prog)

I am referencing Progress.au3

;===============================================================================
;
; Function Name:   _ProgressOn
; Description:: Creates a 'ProgressOn like' progress bar in a gui
; Syntax:          Dim $progress, $main, $sub;make sure you dim the first three variables. they are the controlId's
;                  _ProgressOn($progress, $main, $sub, "This is the main text", "This is the sub-text", 150, 10)
; Parameter(s): $s_mainlabel($main-text var), $s_sublabel($sub-text var),
;                  $s_control($progress var), $s_main(Main text), $s_sub(Sub Text), $x(Position), $y(Position), $fSmooth(1 for smooth, 0 for not smooth)
; Requirement(s):  AutoIt, #include <file.au3>
; Return Value(s): Success - Returns array
;                  $array[0] - $progress id
;                  $array[1] - Main Label
;                  $array[2] - Sub label
;                  $array[3] - x pos
;                  $array[4] - y pos
;                  Failure - 0 and sets @error to 1
; Author(s):       RazerM
;
;===============================================================================
;
Func _ProgressOn(ByRef $s_mainlabel, ByRef $s_sublabel, ByRef $s_control, $s_main, $s_sub, $x, $y, $fSmooth = 0)
    $s_mainlabel = GUICtrlCreateLabel($s_main, $x, $y, StringLen($s_main) * 8,16)
    If $s_mainlabel = 0 Then
        SetError(1)
        Return 0
    EndIf
;GUICtrlSetFont($s_mainlabel, 10)
    If StringInStr(@OSTYPE, "WIN32_NT") And $fSmooth = 1 Then
        $prev = DllCall("uxtheme.dll", "int", "GetThemeAppProperties");, "int", 0)
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
    EndIf
    $s_control = GUICtrlCreateProgress($x, $y + 16, 170, 15, $PBS_SMOOTH)
;$s_control = GUICtrlCreateProgress($x, $y + 30, 260, 20, $PBS_SMOOTH)
    If StringInStr(@OSTYPE, "WIN32_NT") And $fSmooth = 1 Then
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $prev[0])
    EndIf
    If $s_control = 0 Then
        SetError(1)
        Return 0
    EndIf
    $s_sublabel = GUICtrlCreateLabel($s_sub, $x, $y+34)
;GUICtrlSetFont($s_sublabel, 10)
    If $s_sublabel = 0 Then
        SetError(1)
        Return 0
    EndIf
    Dim $a_info[5]
    $a_info[0] = $s_control
    $a_info[1] = $s_mainlabel
    $a_info[2] = $s_sublabel
    $a_info[3] = $x
    $a_info[4] = $y
    Return $a_info
EndFunc ;==>_ProgressOn
;===============================================================================
;
; Function Name:   _ProgressSet
; Description:: Sets a progressbar created with _ProgressOn
; Parameter(s): $a_info(Progress Id returned by _ProgressOn), $i_per(Percent), $s_sub(Sub text)[optional], $s_main(main text)[optional]
; Requirement(s):  AutoIt, #include <file.au3>
; Return Value(s): Success - 1, Failure - 0 and sets @error to 1
; Author(s):       RazerM
;
;===============================================================================
;
Func _ProgressSet($a_info, $i_per, $s_sub = "", $s_main = "")
    If $s_main = "" Then $s_main = GUICtrlRead($a_info[1])
    If $s_sub = "" Then $s_sub = GUICtrlRead($a_info[2])
    $set1 = GUICtrlSetData($a_info[0], $i_per)
    $set2 = GUICtrlSetData($a_info[1], $s_main)
    $set3 = GUICtrlSetData($a_info[2], $s_sub)
    GUICtrlSetPos($a_info[2], $a_info[3], $a_info[4]+34, StringLen($s_sub)*6,16)
    GUICtrlSetPos($a_info[1], $a_info[3], $a_info[4], StringLen($s_main)*8,16)
    If ($set1 = 0) Or ($set2 = 0) Or ($set3 = 0) Then
        SetError(1)
        Return 0
    EndIf
    If ($set1 = -1) Or ($set2 = -1) Or ($set3 = -1) Then
        SetError(1)
        Return 0
    EndIf
    Return 1
EndFunc

;===============================================================================
;
; Function Name:   _ProgressOff()
; Description:: Deletes a progress bar created with _ProgressOn()
; Parameter(s): $a_info(Progress Id returned by _ProgressOn)
; Requirement(s):  AutoIt, #include <file.au3>
; Return Value(s): Success - 1, Failure - 0 and sets @error to 1
; Author(s):       RazerM
;
;===============================================================================
;

Func _ProgressOff($a_info)
    $del1 = GUICtrlDelete($a_info[1])
    $del2 = GUICtrlDelete($a_info[2])
    $del3 = GUICtrlDelete($a_info[0])
    If ($del1 = 0) Or ($del2 = 0) Or ($del3 = 0) Then
        SetError(1)
        Return 0
    EndIf
EndFunc

Any ideas why? Any ideas for a work around?

Note: I added BlockInput(1) before, and BlockInput(0) after the progress bar and it will still crash if the user clicks (again... 80% of the time), even though the mouse/keyboard are disabled.

EDIT: Changed some of the original code layout. Still occasionally crashes. I have no idea why.

Edited by gnosis3d

Share this post


Link to post
Share on other sites



try to get the dllcall error with the getlasterror function


-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites

I couldn't get that GetLastError thing to work (since it crashes, how is it supposed to help?)

Here is a screenshot and the error text file associated with my latest crash.

http://www.wintergray.com/error01.jpg

http://www.wintergray.com/d895_appcompat.txt

Again, this is a crash DIRECTLY AFTER a progress bar/copy function. It does NOT happen all the time. There has to be something causing it, though. I really need a hand on this, as I am stuck at a brick wall.

Share this post


Link to post
Share on other sites

I couldn't get that GetLastError thing to work (since it crashes, how is it supposed to help?)

Here is a screenshot and the error text file associated with my latest crash.

http://www.wintergray.com/error01.jpg

http://www.wintergray.com/d895_appcompat.txt

Again, this is a crash DIRECTLY AFTER a progress bar/copy function. It does NOT happen all the time. There has to be something causing it, though. I really need a hand on this, as I am stuck at a brick wall.

Can you re-create this error with anything other than your actual script?

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.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Can you re-create this error with anything other than your actual script?

I'd hate to post the entire script... it's about 1K lines long. It's a GUI for retrieving FTP files, submitting jobs to an external piece of software, etc etc.

The odd thing is... I have 3 tabs, all with similiar functions which all set parameters then use the same functions.

In one tab, the script works fine. It copies the file, uses the progress bar, and goes on its merry way. The other one crashes. The only difference is where it gets it input from (one is a manual input bar, the other is from a list). But prior to it running, it sets the parameters. The manual input is the ORIGINAL one that I have used since early alpha phases.

To test, I have stripped the entire first tab with manual input out, and it is still fine with the list input.

I can't for the life of me figure out why it crashes. Its the SAME FREAKING FUNCTION...

Differences:

$partnum = ControlGetText("Remote","",$partinput)

$partnum = GUICtrlRead($networkfilelist,1)

That's all the difference is the setting of $partnum to read from a different control...

*pulls hair out*

EDIT: And to clarify, its not that it doesnt DO the function... it crashes AFTER it copies. So the file gets copied, so the $partnum part seems to be fine.

Edited by gnosis3d

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

And get this.

I have this computer to work on and develop, then the computers I put them on.

This one doesn't seem to do it, and is an AMD64 3200+. The other 3 computers are Intel Celerons.

They all are WindowsXP SP2.

Why would a function with a particular TYPE of input = $var not work on an Intel, but work on an AMD?

I'm trying to narrow problems down here, but it keeps becoming more and more of a mystery. (perhaps MISERY...)

Edited by gnosis3d

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

This is the copyCD() function.

Func copyCD()
    If FileExists($inprogressdir & $partnum & ".cdi") Then
        $answer = MsgBox(4, "Confirm Overwrite", "You will be overwriting a CDI file in the Local Folder. Are you sure?")
        If $answer = 6 Then
            $netDnFileSize = InetGetSize("ftp://" & $FTPaccess & $FTPserver & $FTPdir & $partnum & ".cdi")
            If $netDnFileSize = 4294967295 Then
                $netDnFileSize = 0
            Else
                $prog = _ProgressOn($progress,$main,$sub,$partnum,"",16,248,1)
                InetGet("ftp://" & $FTPaccess & $FTPserver & $FTPdir & $partnum & ".cdi", $inprogressdir & $partnum & ".cdi",1,1)
            ; need to divide by 1048576 also, variables that don't change should be outside loop
                $FileSize = $netDnFileSize/1048576
                $netfiledownload = round($netDnFileSize/1048576, 1)
                Do
                    $filedownload = round(@InetGetBytesRead/1048576, 1)
                    $Percent = Round(($filedownload/$FileSize)*100);need to mutliply by 10 to get percentage
                    _ProgressSet($prog, $Percent,"Copied " & $filedownload & " MB of " & $netfiledownload & " MB")
                    Sleep(1250)
                Until FileGetSize($inprogressdir & $partnum & ".cdi") = $netDnFileSize
                sleep(250)
                _ProgressOff($prog)
                sleep(250)
            EndIf
        Else
            sleep(2)
        EndIf
    Else
        $netDnFileSize = InetGetSize("ftp://" & $FTPaccess & $FTPserver & $FTPdir & $partnum & ".cdi")
        If $netDnFileSize = 4294967295 Then
            $netDnFileSize = 0
        Else
            $prog = _ProgressOn($progress,$main,$sub,$partnum,"",16,248,1)
            InetGet("ftp://" & $FTPaccess & $FTPserver & $FTPdir & $partnum & ".cdi", $inprogressdir & $partnum & ".cdi",1,1)
        ; need to divide by 1048576 also, variables that don't change should be outside loop
            $FileSize = $netDnFileSize/1048576
            $netfiledownload = round($netDnFileSize/1048576, 1)
            Do
                $filedownload = round(@InetGetBytesRead/1048576, 1)
                $Percent = Round(($filedownload/$FileSize)*100);need to mutliply by 10 to get percentage
                _ProgressSet($prog, $Percent,"Copied " & $filedownload & " MB of " & $netfiledownload & " MB")
                Sleep(1250)
            Until FileGetSize($inprogressdir & $partnum & ".cdi") = $netDnFileSize
            sleep(250)
            _ProgressOff($prog)
            sleep(250)
        EndIf
        If $netDnFileSize = 0 Then
            If FileExists($inprogressdir & $partnum & ".iso") Then
                $answer = MsgBox(4, "Confirm Overwrite", "You will be overwriting a ISO file in the Local Folder. Are you sure?")
                If $answer = 6 Then
                    $netDnFileSize = InetGetSize("ftp://" & $FTPaccess & $FTPserver & $FTPdir & $partnum & ".iso")
                    If $netDnFileSize = 4294967295 Then
                        $netDnFileSize = 0
                        MsgBox(4096,"Warning","CD file does not exist. Check the Client Selection and Part Number.")
                    Else
                        $prog = _ProgressOn($progress,$main,$sub,$partnum,"",16,248,1)
                        InetGet("ftp://" & $FTPaccess & $FTPserver & $FTPdir & $partnum & ".iso", $inprogressdir & $partnum & ".iso",1,1)
                    ; need to divide by 1048576 also, variables that don't change should be outside loop
                        $FileSize = $netDnFileSize/1048576
                        $netfiledownload = round($netDnFileSize/1048576, 1)
                        Do
                            $filedownload = round(@InetGetBytesRead/1048576, 1)
                            $Percent = Round(($filedownload/$FileSize)*100);need to mutliply by 10 to get percentage
                            _ProgressSet($prog, $Percent,"Copied " & $filedownload & " MB of " & $netfiledownload & " MB")
                            Sleep(1250)
                        Until FileGetSize($inprogressdir & $partnum & ".iso") = $netDnFileSize
                        sleep(250)
                        _ProgressOff($prog)
                        sleep(250)
                    EndIf
                Else
                    sleep(2)
                EndIf
            Else
                $netDnFileSize = InetGetSize("ftp://" & $FTPaccess & $FTPserver & $FTPdir & $partnum & ".iso")
                If $netDnFileSize = 4294967295 Then
                    $netDnFileSize = 0
                    MsgBox(4096,"Warning","CD file does not exist. Check the Client Selection and Part Number.")
                Else
                    $prog = _ProgressOn($progress,$main,$sub,$partnum,"",16,248,1)
                    InetGet("ftp://" & $FTPaccess & $FTPserver & $FTPdir & $partnum & ".iso", $inprogressdir & $partnum & ".iso",1,1)
                ; need to divide by 1048576 also, variables that don't change should be outside loop
                    $FileSize = $netDnFileSize/1048576
                    $netfiledownload = round($netDnFileSize/1048576, 1)
                    Do
                        $filedownload = round(@InetGetBytesRead/1048576, 1)
                        $Percent = Round(($filedownload/$FileSize)*100);need to mutliply by 10 to get percentage
                        _ProgressSet($prog, $Percent,"Copied " & $filedownload & " MB of " & $netfiledownload & " MB")
                        Sleep(1250)
                    Until FileGetSize($inprogressdir & $partnum & ".iso") = $netDnFileSize
                    sleep(250)
                    _ProgressOff($prog)
                    sleep(250)
                EndIf
            EndIf
        Else
            sleep(2)
        EndIf
    EndIf
EndFunc
Edited by Larry

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

More testing...

As far as I can tell, it only (or at least mostly) happens on the Intel boxes. Now, they all are Windows XP SP2, including the AMD64 I use to dev.

I stripped the List input and just used the Manual input and it still crashes. List input works fine with and without the Manual being commented out.

It seems that it crashes after I do the function a 2nd time (from what I've tested in the past hour). Has anyone encountered problems with variables or functions not "reseting" for a lack of a better term? It still completes the function, but somehow it crashes after the fact. Perhaps Global, Dim, Local $var issues I am overlooking?

*getting ready to go Postal*

There has to be some small fundamental issue I am overlooking, but since it is calling the same function I am still baffled.

Edited by gnosis3d

Share this post


Link to post
Share on other sites

More testing...

As far as I can tell, it only (or at least mostly) happens on the Intel boxes. Now, they all are Windows XP SP2, including the AMD64 I use to dev.

I stripped the List input and just used the Manual input and it still crashes. List input works fine with and without the Manual being commented out.

It seems that it crashes after I do the function a 2nd time (from what I've tested in the past hour). Has anyone encountered problems with variables or functions not "reseting" for a lack of a better term? It still completes the function, but somehow it crashes after the fact. Perhaps Global, Dim, Local $var issues I am overlooking?

*getting ready to go Postal*

There has to be some small fundamental issue I am overlooking, but since it is calling the same function I am still baffled.

Is the script actually crashing or is it getting into an endless loop?

If it's crashing then there should be an error message with the line number that can be checked

If it's an endless loop then comment anything that is hiding the tray icon and add the line Opt("TrayIconDebug",1) at the beginning of the script. Then you should be able to hover over the icon and see where you are getting into the loop.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Opt("TrayIconDebug",1)

Seems to only crash when compiled to an EXE. And the tray icon says "Line: Sleep(1000)" rather than the usual addition of a line number (i guess since its compiled?)

So are there some compiling issues I am not aware of?

EDIT:

It has to be going back to the mainmenu() function I have where the following code is:

Func mainmenu()
...
buttons and stuff
...
    While 1
        Sleep(1000)
    WEnd
EndFunc

So I am guessing that it his back to the mainmenu and crashes; hence why it was bugging me that it FINISHED the function it calls (copying/progress bar) and THEN dies. Perhaps I am doing the mainmenu incorrectly?

NOTE: Still only crashes on my Intel Celeron PCs; not my AMD64. (all winxp sp2)

Edited by gnosis3d

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