Jump to content
Sign in to follow this  
brian873

Progress Bar

Recommended Posts

brian873

Hi, I would like to create a progress bar that displays the percentage of a filecopy that is run from a system tray menu.

I have looked through the help but cant see how to get the percentage information in to the progress bar, and my head is starting to hurt!

Can anyone help?

Thanks

Share this post


Link to post
Share on other sites
Achilles

Hi, I would like to create a progress bar that displays the percentage of a filecopy that is run from a system tray menu.

I have looked through the help but cant see how to get the percentage information in to the progress bar, and my head is starting to hurt!

Can anyone help?

Thanks

Use

#include <GUIConstants.au3>

GUICreate("My GUI Progressbar",220,100, 100,200)
$progressbar1 = GUICtrlCreateProgress (10,10,200,20)
GUICtrlSetColor(-1,32250); not working with Windows XP Style
$progressbar2 = GUICtrlCreateProgress (10,40,200,20,$PBS_SMOOTH)
$button = GUICtrlCreateButton ("Start",75,70,70,20)
GUISetState ()

$wait = 20; wait 20ms for next progressstep
$s = 0; progressbar-saveposition
do
$msg = GUIGetMsg()
If $msg = $button Then
    GUICtrlSetData ($button,"Stop")
    For $i = $s To 100
    If GUICtrlRead($progressbar1) = 50 Then Msgbox(0,"Info","The half is done...", 1)
    $m = GUIGetMsg ()
    
    If $m = -3 Then ExitLoop
    
    If $m = $button Then
      GUICtrlSetData ($button,"Next")
      $s = $i;save the current bar-position to $s
      ExitLoop
    Else
        $s=0
      GUICtrlSetData ($progressbar1,$i)
      GUICtrlSetData ($progressbar2,(100 - $i))
      Sleep($wait)
    EndIf
    Next
    if $i >100 then
;      $s=0
        GUICtrlSetData ($button,"Start")
    endif
EndIf
until $msg = $GUI_EVENT_CLOSE

Or

ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(500)
    ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()
Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites
brian873

Thanks for taking time to reply Piano_man!

Sorry to be a pain but I still don't understand were my filecopy command would go to tie in with the progress bar?

Could you help???

thanks

Share this post


Link to post
Share on other sites
Achilles

Thanks for taking time to reply Piano_man!

Sorry to be a pain but I still don't understand were my filecopy command would go to tie in with the progress bar?

Could you help???

thanks

Well, I think that for a single FileCopy() you can't get the percent. Are you doing one file or multiple files?

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites
brian873

It is a single file but it is 800mb coming from a USB drive, so it can take a few minutes.

I would like to have it built in to my script with a progress bar. But if not I found this code yesterday that would do but its not a progress bar.

I hope you can help :)

Dim $source = "C:\bc\test"
Dim $target = "C:\bc\1"

_FileCopy($source, $target)

Func _FileCopy($fromFile,$tofile)
    Local $FOF_RESPOND_YES = 16
    Local $FOF_SIMPLEPROGRESS = 256
    $winShell = ObjCreate("shell.application")
    $winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES)
EndFunc

Share this post


Link to post
Share on other sites
Achilles

Ugh, I don't know much about objects....

Just an off the wall suggestion that probably won't work and that I'm too lazy to try:

Try InetGet() for your file, that will give you the percentage if you calculate it right... I kind of doubt it lets you download stuff from a USB port instead of the internet though...


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites
brian873

Thanks Piano man I'll keep searching!

Share this post


Link to post
Share on other sites
brian873

Thanks Danny Just what I am looking for!

I tried this script and had a problem so I will continue in that post.

Thanks everyone for your help!

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  

×