Jump to content

Progress Bar


brian873
 Share

Recommended Posts

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

Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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