Sign in to follow this  
Followers 0
Terenz

Math and progressbar

11 posts in this topic

#1 ·  Posted (edited)

Hi,

Everytime is always hard for me to explain all the situation :D

So, i need to "monitor" a file download from a different software, example this file is called:

File1.exe.part

Of this file i know the original size, File1.exe, example it is 10MB

I'm using Adlib in this way:

AdlibRegister("_Monitor")

Func __Monitor()
    Local Static $iStartingSize = 10000 ; 10MB, i'll change the value dinamically
    Local $iCurrentSize = FileGetSize("File1.exe.part")
    If $iCurrentSize <> $iPreviousSize Then
        $iPreviousSize = $iCurrentSize
        GUICtrlSetData($hProgress, Int($iCurrentSize / ($iStartingSize) * 100))
    EndIf
EndFunc   ;==>__MonitorFile_Crypt

Until that work, i'm fill the progressbar at 100% and i know when is done using WinGetHandle of the original software for stopping it.

But with 1 file... but i have more than 1 :D

Example if i have 4 file the progressbar need to fill at 100% only if all the files are download.

Pratically from 0 to 25% file 1, from 25% to 50% file 2 but always base this value on the real size of the file.

The question is, How to use GUICtrlSetData for partially fill the progressbar like from 0-25 25-50 instead of from 0 to 100% but always based on filesize?

If something is not clear...i can't post any code this time i don't know how to reproduce the script

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

How about to create 2 progress bars - 1 for current download and 2 for overall?

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

I prefer only one for everything, i'll use your suggestion only if no other solution avaiable.


Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Do you know the sizes of every file before download ?. If so, its inmediate, dont ?

Edited by zalomalo

My english shucks, i know it.

Share this post


Link to post
Share on other sites

Here a way:

Global Const $hGUI = GUICreate("Test", 600, 300)
Global Const  $iLabel = GUICtrlCreateLabel("", 10, 50, 580, 90)
GUICtrlSetFont(-1, 50)
Global Const $iProgressbar = GUICtrlCreateProgress( 10, 200, 580, 20)
GUISetState()

Global $aFile[4][3] = [["File1.exe", 0, 50], ["File2.exe", 0, 100], ["File3.exe", 0, 75], ["File4.exe", 0, 25]]
Global $iFiles = UBound($aFile), $iPart = 0

AdlibRegister("Progress", 100)

Do
    Switch GUIGetMsg()
        Case -3
            AdlibUnRegister("Progress")
            Exit
    EndSwitch
Until False

Func Progress()
    GUICtrlSetData($iLabel, $aFile[$iPart][0])
    GUICtrlSetData($iProgressbar, ($aFile[$iPart][1] / $aFile[$iPart][2] * 100) * 1 / $iFiles + ($iPart * 100 / $iFiles))
    WinSetTitle($hGUI, "", StringFormat("%.2f %", ($aFile[$iPart][1] / $aFile[$iPart][2] * 100) * 1 / $iFiles))
    $aFile[$iPart][1] += 1
    If $aFile[$iPart][1] > $aFile[$iPart][2] Then
        $iPart += 1
        GUISetBkColor(Random(0x400000, 0x800000, 1), $hGUI)
    EndIf
    If $iPart >= $iFiles Then AdlibUnRegister("Progress")
EndFunc

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

UEZ i have some problem, sometimes i have strange value that make the progressbar crazy :D

See in 7-13-8 or 28-57-28 and so on.

Do you know how i can resolve?

EDIT: I'm still working on it

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites

I assume that your $iCurrentSize and/or $iStartingSize value(s) "go(es) crazy"!


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Probably but with only one file using Int($iCurrentSize / ($iStartingSize) * 100) i don't have any problems  :ermm:

Instead using that formula still having issue, i'm debugging my code for check if there are any error but for now i don't have found nothing


Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I'm reup the thread again because my values goes crazy so i need to change approach.

Assuming i know this time the total file size of all the files:

Global $aFile[4][3] = [["File1.exe", 0, 50], ["File2.exe", 0, 100], ["File3.exe", 0, 75], ["File4.exe", 0, 25]]
Global $iFiles = UBound($aFile), $iTotalbyte = 250, $iPart = 0

And i want to check "byte by byte" until i reach $iTotalbyte, always one progressbar for all, what is the formula to apply? Thanks again

Because if i'm using Int($iCurrentSize / ($iTotalbyte) * 100)) for the value $iCurrentSize i have something like:

0
120
150 ; end of file
0
12
35 ; end of file
0
etc.

So the progress start from zero each time and not from the previus size...and i can't sum value or it will be more then the $iTotalbyte ( example $iTotalbyte = 185 - 0+120+150+0+12+35 = too much instead 150+35=185 but with a progress bar :D )

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites

ConsoleWrite the values every time you perform the calculation, this should indicate what is going wrong.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

If i know what calculation i need to do...post #5 was correct but i can't apply to my case so i need to chage approach and using the current byte / total byte instead of splitting the progress bar in "parts" like that post do.

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

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