Sign in to follow this  
Followers 0
gcue

true progressbar

20 posts in this topic

does anyone have any ideas for a true progressbar?

one that actually looks like it matches up with the process wait?

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

He means he's running a process and want his progress bar to match the evolution of his process. 0% done at the start of the process.. 100% done when process is over. And obviously we can't answer since we don't know what he wants his progress bar to be in relation with... It's up to him to check how far he is in his process execution and pass the info to the progress bar...

Example.. your process = a function that copy a directory to another directory

your check function = compare source directory size to (current) destination directory size.. once both match.. progress = 100%

and in-between... up to you if want your progress bar to jump by 1% .. 10% .. 20% .. and the impact this check function would have on your script efficiency.. checking every milliseconds would be dumb for example.. every second is much better.

Edited by MikeP

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Yea its not going to happen. How would a progressbar for ProcessWait() even be useful? The whole purpose of ProcessWait() is to stop your script because it has no idea when the process will start, therefore you have no metric to use for the progress.

EDIT: 3000th post and all I got was this crappy t-shirt

Edited by weaponx

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Oh, well by the time it's executed then it would be full.

Ahah :)

EDIT: 3000th post and all I got was this crappy t-shirt

Congratz weaponx ! (and this is priceless ! worth more than a t-shirt) Edited by MikeP

Share this post


Link to post
Share on other sites

I've found that sometimes (when creating something that users will see) it's nice to show at least an animated progressbar to show that "something is happening."

Share this post


Link to post
Share on other sites

You're right.. using fake progress bar can be useful and ergonomic.. there's nothing worse than wondering if the script is actually running or not, finished or not.

Share this post


Link to post
Share on other sites

then how about a bar that scrolls from left to right and says "checking"

know what i mean?

i think that would be less misleading.. how would that be coded?

Share this post


Link to post
Share on other sites

#11 ·  Posted

There is no universal measure of progress. When you create a progress bar it should visually represent a step in your code. Say you have 10 steps in your code, you might add 10% after each step to achieve 100%.

The same goes for file copying. Say you have 100 files, if you need to see the progress in terms of number of files copied, each file equals 1%.

File 1 copy...1%

File 2 copy...2%

...

File 99 copy...99%

File 100 copy...100%

If you need to see progress in terms of bytes copied, each file is a fraction of the total size of all files combined.

Total filesize = 100 bytes

File 1 copy (50 bytes)...50%

File 2 copy (25 bytes)...75%

File 3 copy (20 bytes)...95%

File 4 copy (5 bytes)...100%

Share this post


Link to post
Share on other sites

#12 ·  Posted

Something like this? Found it between my Scripts :)

_ProcessWaitProgress("taskmgr.exe")
;===============================================================================
;
; Function Name:   _ProcessWaitProgress($Process,$timeout = -1,  $speed = 1)
; Description::    Shows an Progressbar while Waiting on a Process
; Parameter(s):    $Process - PID or Name of Process
;                  $timeout - Timeout in Seconds,  -1 (Default): No TimeOut
;                  $speed   - Speed of moving Progressbar
; Requirement(s):  ??
; Return Value(s): 1, if success, o and @error=1 If TimeOUt
; Author(s):       Prog@ndy
;
;===============================================================================
;
Func _ProcessWaitProgress($Process,$timeout = -1,  $speed = 1)
    Local $perc = 0, $dir = 1, $elapsed, $tim
    ProgressOn("Waiting for Process","Waiting for "& $Process,"Waiting for TaskMgr starting")
    $tim = TimerInit()
    While 1
        $perc += $speed*$dir
        if $perc >= 100 Then 
            $dir = -1
        ElseIf $perc <= 0 Then
            $dir = 1
        EndIf
        $elapsed = Round(TimerDiff($tim)/1000)
        ProgressSet($perc,"Elapsed time: " & $elapsed & "s")
        If ProcessExists($Process) Then ExitLoop
        If $timeout > 0 And $elapsed >= $timeout Then
            ProgressOff()
            Return SetError(1,0,0)
        EndIf
        Sleep(50)
    WEnd
    ProgressOff()
    Return 1
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#13 ·  Posted

The progressbar serves no purpose here. A traytip or popup window thats says "Waiting for process..." and a time counter would suffice, since the time can be zero to infinity an open ended counter is best.

Share this post


Link to post
Share on other sites

#14 ·  Posted

Another option for an open ended Progressbar is to use the $PBS_MARQUEE = 0x00000008. This to me gives the obvious visual result of an open ended Wait process.


There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

do you guys know what i mean?

a progressbar that goes to 100% then back to 0% then back to 100% then back to 0% (till the task completes)

of course not displaying the %s.. this would just show that theres activity in the background.

Edited by gcue

Share this post


Link to post
Share on other sites

#16 ·  Posted

do you guys know what i mean?

a progressbar that goes to 100% then back to 0% then back to 100% then back to 0% (till the task completes)

of course not displaying the %s.. this would just show that theres activity in the background.

Ummm...thats exactly what ProgAndy posted for you.

Share this post


Link to post
Share on other sites

#18 ·  Posted

doh!

i had type up my post and hadnt seen his post by the time i submitted.

thanks man

Ummm...thats exactly what ProgAndy posted for you.

Share this post


Link to post
Share on other sites

#19 ·  Posted

I would like to congratulate ProgAndy. For what ? for understanding what the thread maker was meaning :) .. before his "do you guys know what I mean?" post ... gj andy !!!

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Here's another take on this, combining something RazerM did ( http://www.autoitscript.com/forum/index.ph...st&p=370254 ) with the concept of ProgAndy

I combined some of RazerM's seperated functions into the main loop.

;original progress concept by RazerM, based on googemyster
;http://www.autoitscript.com/forum/index.php?s=&showtopic=48977&view=findpost&p=370254


_ProcessWaitProgress("taskmgr.exe", "Waiting For Taskmanager...", 10, 2) 

Func _ProcessWaitProgress($process, $sLabelCaption = "", $timeout = 0, $speed = 1)
;Usage: _ProcessWaitProgress($process, $caption, $timeout, $speed) 
;Returns 1 on Progress Started, 0 on timeout with @error set to 1

    $GuiCloseMode = Opt("GUICloseOnESC", 0) ;get & set Esc Close Mode
    #include <GUIConstants.au3>
    Local $aLabel[50], $Ca, $Da, $elapsed, $tim
    Local $backClr = 0xFFFFFF ;white,
    Local $foreClr = 0x009A31;green ;0xFF0000 red
    Local $aColors = _ColorGradient($backClr, $foreClr, 50)

    $Ca = GUICreate("", 250, 46, -1, -1, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_WINDOWEDGE + $WS_EX_DLGMODALFRAME)
    GUISetBkColor(0x000000, $Ca)
    $Da = GUICtrlCreateLabel($sLabelCaption, 23, 1, 250, 23) ; $SS_CENTER)
    GUICtrlCreateGraphic(-1, 1, 252, 45, $SS_SUNKEN)
    GUICtrlSetColor(-1, 0XFFFFFF)
    GUICtrlSetColor($Da, 0XFFFFFF)
    GUICtrlSetFont($Da, "10", "50");, "", "Palatino LinoType Italic")
    GUISetState(@SW_SHOW)
    GUICtrlCreateGraphic(1, 23, 250, 20)

    For $i = 0 To 245 Step 5
        ;we divide i by 5 because of step 5. 0/5 = 0, 5/5 = 1, 10/5 = 2
        $aLabel[$i / 5] = GUICtrlCreateLabel("", $i, 25, 4, 16)
    Next

    $tim = TimerInit()

    While Not ProcessExists($process)
        ;SlideRight
        For $m = 0 To 245 Step 5
            GUICtrlSetBkColor($aLabel[$m / 5], $aColors[$m / 5])
            Sleep(50/$speed)
            $elapsed = Round(TimerDiff($tim) / 1000)
            If ProcessExists($process) Or ($timeout > 0 And $elapsed >= $timeout) Then
                $ReturnVal = _ExitFunc($timeout, $elapsed)
                SetError(@error)
                Opt(Opt("GUICloseOnESC", $GuiCloseMode)
                Return ($ReturnVal)
            EndIf
        Next
        _getmsg()

        ;SlideLeft
        For $m = 245 To 0 Step -5
            GUICtrlSetBkColor($aLabel[$m / 5], $aColors[49 - $m / 5]) ;49- so that colours are opposite from _Slider Right colours
            Sleep(50/$speed)
            $elapsed = Round(TimerDiff($tim) / 1000)
            If ProcessExists($process) Or ($timeout > 0 And $elapsed >= $timeout) Then
                $ReturnVal = _ExitFunc($timeout, $elapsed)
                SetError(@error)
                Opt(Opt("GUICloseOnESC", $GuiCloseMode)
                Return ($ReturnVal)
            EndIf
        Next
        _getmsg()
    WEnd
EndFunc   ;==>_ProcessWaitProgress


Func _ExitFunc($timeout, $elapsed)
    If $timeout > 0 And $elapsed >= $timeout Then
        Return SetError(1, 0, 0)
    EndIf
    Return 1
EndFunc   ;==>_ExitFunc


Func _getmsg()
    $Msg = GUIGetMsg()
    If $Msg = $GUI_EVENT_CLOSE Then Exit
    ;put something to stop progressbar
EndFunc   ;==>_getmsg


;this function was written by CoePSX
Func _ColorGradient($hInitialColor, $hFinalColor, $iReturnSize)
    $hInitialColor = Hex($hInitialColor, 6)
    $hFinalColor = Hex($hFinalColor, 6)

    Local $iRed1 = Dec(StringLeft($hInitialColor, 2))
    Local $iGreen1 = Dec(StringMid($hInitialColor, 3, 2))
    Local $iBlue1 = Dec(StringMid($hInitialColor, 5, 2))

    Local $iRed2 = Dec(StringLeft($hFinalColor, 2))
    Local $iGreen2 = Dec(StringMid($hFinalColor, 3, 2))
    Local $iBlue2 = Dec(StringMid($hFinalColor, 5, 2))

    Local $iPlusRed = ($iRed2 - $iRed1) / ($iReturnSize - 1)
    Local $iPlusBlue = ($iBlue2 - $iBlue1) / ($iReturnSize - 1)
    Local $iPlusGreen = ($iGreen2 - $iGreen1) / ($iReturnSize - 1)

    Dim $iColorArray[$iReturnSize]
    For $i = 0 To $iReturnSize - 1
        $iNowRed = Floor($iRed1 + ($iPlusRed * $i))
        $iNowBlue = Floor($iBlue1 + ($iPlusBlue * $i))
        $iNowGreen = Floor($iGreen1 + ($iPlusGreen * $i))
        $iColorArray[$i] = Dec(Hex($iNowRed, 2) & Hex($iNowGreen, 2) & Hex($iNowBlue, 2))
    Next
    Return $iColorArray
EndFunc   ;==>_ColorGradient
Edited by ResNullius

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