Jump to content

Multiple ProgressBar issues


DigDeep
 Share

Recommended Posts

@R0G  you had helped me few months ago to fix the Progress bar issues with percentage and Filesize. the solution works all great until now when I found that if I am trying to use multiple progress bars at certain intervals, the files get downloaded properly but either both the Progressbars do not show any status or the 2nd one does not.

This is a test sample I have here which is similar to what I am trying to get. Not sure but I think the Func Filesize which I am using is creating the issue here which is used inside all the progress functions. I even tried to create 2 functions as Func FileSize1() and Func FileSize2() with all variables with different names but it still does the same.

Just a thought that it would be great if I can use 1 Func FileSize() as:

Global $FlagClear = 0

Func FileSize($TDown, Const $Place) ; Get file size

if $FlagClear = 0 then
    Local Static $aSize[4] = ["Bytes", "KB", "MB", "GB"]
    For $a = 0 To 3
        $TDown /= 1024
        If (Int($TDown) = 0) Then Return Round($TDown * 1024, $Place) & " " & $aSize[$a]
    Next

$FlagClear = 1

Endif
EndFunc   ;==>FileSize

 

Could you or anyone please help?

 

#RequireAdmin
#NoTrayIcon

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <ProgressConstants.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $Place
Global $Download = 9999

main()

Func main()

    $Form2 = GUICreate("Form2", 626, 491, 466, 301)
    $Download = GUICtrlCreateButton("Download", 264, 416, 150, 25)
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Select
            Case $nMsg = $GUI_EVENT_CLOSE
                Exit
            Case $nMsg = $Download
                VLC()
                Sleep(3000)
                Flash()
        EndSelect
    WEnd
EndFunc

Func FileSize($TDown, Const $Place) ; Get file size
    Local Static $aSize[4] = ["Bytes", "KB", "MB", "GB"]
    For $a = 0 To 3
        $TDown /= 1024
        If (Int($TDown) = 0) Then Return Round($TDown * 1024, $Place) & " " & $aSize[$a]
    Next
EndFunc   ;==>FileSize

Func VLC()
    $DownloadLbl = GUICtrlCreateLabel(@CRLF & @CRLF & 'Installing VLC Player...', 232, 112, 345, 193)
    $LBL_Percent = GUICtrlCreateLabel("", 232, 256, 45, 30) ; Show % lable
    $LBL_Size = GUICtrlCreateLabel("", 232, 272, 45, 30) ; Show File size lable
    GUICtrlSetFont(-1, 11, 400, 0, "Arial")
    Local $sfldr = "C:\Temp"
    DirCreate($sfldr)
    Local $Src = "http://get.videolan.org/vlc/2.2.4/win32/vlc-2.2.4-win32.exe" ;Set URL
    $Dest = $sfldr & '\vlc.exe' ;Set folder
    $Down = InetGet($Src, $Dest, 1, 1)
    $SrcSize1 = InetGetSize($Src) ;Get file size
    Local $idProgressbar1 = GUICtrlCreateProgress(288, 256, 238, 17)
    GUICtrlSetColor(-1, 32250); not working with Windows XP Style
    Local $Size = InetGetSize($Src,1) ;get the size of the update
    While Not InetGetInfo($Down, 2)
        Sleep(100)
        $DownldBytes = InetGetInfo($Down, 0) ;Get bytes received
        $Percent = Int($Down / $Size * 100) ;Calculate percentage
;~         Local $Percent = Round((InetGetInfo($Down,0)/$Size)*100)
        $TSize = $SrcSize1 - $DownldBytes
        GUICtrlSetData($idProgressbar1,$Percent)
        GUICtrlSetData($DownloadLbl, FileSize($TSize, $Place = 2))
        GUICtrlSetData($LBL_Percent,$Percent & "%")
        Sleep(100)
    WEnd
    GUICtrlSetState($DownloadLbl, $GUI_HIDE)
EndFunc


Func Flash()
    $FLashLbl = GUICtrlCreateLabel(@CRLF & @CRLF & 'Installing Adobe Flash Player...', 232, 112, 345, 193)
    $LBL_Percent = GUICtrlCreateLabel("", 232, 256, 45, 30) ; Show % lable
    $LBL_Size = GUICtrlCreateLabel("", 232, 272, 45, 30) ; Show File size lable
    GUICtrlSetFont(-1, 11, 400, 0, "Arial")
    Local $sfldr = "C:\Temp"
    DirCreate($sfldr)
    Local $Src = "http://download.windowsupdate.com/c/msdownload/update/software/updt/2016/08/windows10.0-kb3189031-x64_c7005a17908712ef9c7eee7389343900da6cee08.msu" ;Set URL
    $Dest = $sfldr & '\Flash.exe' ;Set folder
    $Down = InetGet($Src, $Dest, 1, 1)
    $SrcSize1 = InetGetSize($Src) ;Get file size
    Local $idProgressbar1 = GUICtrlCreateProgress(288, 256, 238, 17)
    GUICtrlSetColor(-1, 32250); not working with Windows XP Style
    Local $Size = InetGetSize($Src,1) ;get the size of the update
    While Not InetGetInfo($Down, 2)
        Sleep(100)
        $DownldBytes = InetGetInfo($Down, 0) ;Get bytes received
        $Percent = Int($Down / $Size * 100) ;Calculate percentage
;~         Local $Percent = Round((InetGetInfo($Down,0)/$Size)*100)
        $TSize = $SrcSize1 - $DownldBytes
        GUICtrlSetData($idProgressbar1,$Percent)
        GUICtrlSetData($FLashLbl, FileSize($TSize, $Place = 2))
        GUICtrlSetData($LBL_Percent,$Percent & "%")
        Sleep(100)
    WEnd
    GUICtrlSetState($FLashLbl, $GUI_HIDE)
EndFunc

 

Link to comment
Share on other sites

No, not at the same time.

If there are multiple buttons in a gui, clicking on button 1 will do:

Step 1. Run some steps with progress window. Complete that.

Step 2. Run some steps with progress window. Complete that.

Step 3...

Step 4...

...

Clicking on button 2 will again get some steps done with progress window.

Now the point is that I do not have the progress on each step. But most of them.

Edited by DigDeep
Link to comment
Share on other sites

Try this:

#RequireAdmin
#NoTrayIcon

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <ProgressConstants.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $Place
Global $Download = 9999

main()

Func main()

    $Form2 = GUICreate("Form2", 626, 491, 466, 301)
    $Download = GUICtrlCreateButton("Download", 264, 416, 150, 25)
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Select
            Case $nMsg = $GUI_EVENT_CLOSE
                Exit
            Case $nMsg = $Download
                VLC()
                Sleep(3000)
                Flash()
        EndSelect
    WEnd
EndFunc

Func FileSize($TDown, Const $Place) ; Get file size
    Local Static $aSize[4] = ["Bytes", "KB", "MB", "GB"]
    For $a = 0 To 3
        $TDown /= 1024
        If (Int($TDown) = 0) Then Return Round($TDown * 1024, $Place) & " " & $aSize[$a]
    Next
EndFunc   ;==>FileSize

Func VLC()
    $DownloadLbl = GUICtrlCreateLabel(@CRLF & @CRLF & 'Installing VLC Player...', 232, 112, 345, 193)
    $LBL_Percent = GUICtrlCreateLabel("", 232, 256, 45, 30) ; Show % lable
    $LBL_Size = GUICtrlCreateLabel("", 232, 272, 45, 30) ; Show File size lable
    GUICtrlSetFont(-1, 11, 400, 0, "Arial")
    Local $sfldr = "C:\Temp"
    DirCreate($sfldr)
    Local $Src = "http://get.videolan.org/vlc/2.2.4/win32/vlc-2.2.4-win32.exe" ;Set URL
    $Dest = $sfldr & '\vlc.exe' ;Set folder
    $Down = InetGet($Src, $Dest, 1, 1)
    $SrcSize1 = InetGetSize($Src) ;Get file size
    Local $idProgressbar1 = GUICtrlCreateProgress(288, 256, 238, 17)
    GUICtrlSetColor(-1, 32250); not working with Windows XP Style
    ;Local $Size = InetGetSize($Src,0) ;get the size of the update
    While Not InetGetInfo($Down, 2)
        Sleep(100)
        $DownldBytes = InetGetInfo($Down, 0) ;Get bytes received
        $Percent = Int(($DownldBytes / $SrcSize1) * 100) ;Calculate percentage
;~         Local $Percent = Round((InetGetInfo($Down,0)/$Size)*100)
        $TSize = $SrcSize1 - $DownldBytes
        GUICtrlSetData($idProgressbar1,$Percent)
        GUICtrlSetData($DownloadLbl, FileSize($TSize, $Place = 2))
        GUICtrlSetData($LBL_Percent,$Percent & "%")
        Sleep(100)
    WEnd
    GUICtrlSetState($DownloadLbl, $GUI_HIDE)
EndFunc


Func Flash()
    $FLashLbl = GUICtrlCreateLabel(@CRLF & @CRLF & 'Installing Adobe Flash Player...', 232, 112, 345, 193)
    $LBL_Percent = GUICtrlCreateLabel("", 232, 256, 45, 30) ; Show % lable
    $LBL_Size = GUICtrlCreateLabel("", 232, 272, 45, 30) ; Show File size lable
    GUICtrlSetFont(-1, 11, 400, 0, "Arial")
    Local $sfldr = "C:\Temp"
    DirCreate($sfldr)
    Local $Src = "http://download.windowsupdate.com/c/msdownload/update/software/updt/2016/08/windows10.0-kb3189031-x64_c7005a17908712ef9c7eee7389343900da6cee08.msu" ;Set URL
    $Dest = $sfldr & '\Flash.exe' ;Set folder
    $Down = InetGet($Src, $Dest, 1, 1)
    $SrcSize1 = InetGetSize($Src) ;Get file size
    Local $idProgressbar1 = GUICtrlCreateProgress(288, 216, 238, 17)
    GUICtrlSetColor(-1, 32250); not working with Windows XP Style
    ;Local $Size = InetGetSize($Src,0) ;get the size of the update
    While Not InetGetInfo($Down, 2)
        Sleep(100)
        $DownldBytes = InetGetInfo($Down, 0) ;Get bytes received
        $Percent = Int(($DownldBytes / $SrcSize1) * 100) ;Calculate percentage
;~         Local $Percent = Round((InetGetInfo($Down,0)/$Size)*100)
        $TSize = $SrcSize1 - $DownldBytes
        GUICtrlSetData($idProgressbar1,$Percent)
        GUICtrlSetData($FLashLbl, FileSize($TSize, $Place = 2))
        GUICtrlSetData($LBL_Percent,$Percent & "%")
        Sleep(100)
    WEnd
    GUICtrlSetState($FLashLbl, $GUI_HIDE)
EndFunc

 

 

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

Sorry for the delay. Was packed up with work here.

Yes, I tried it out few hours ago and it's working like charm. Thank you for being there.

I was also trying out with the same process using FileCopy option instead of InetGet but not sure what to put inplace of InetGetInfo. If you can let me know or else if you need I can share the code I have changed so far and you can check then.

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...