Sign in to follow this  
Followers 0
Pies

I can't understand how to make the progress bar to work (Resolved)

9 posts in this topic

#1 ·  Posted (edited)

Hi everyone, I've been reading some topics here about the progress bar, well I got a code here on how to make a progress bar but what I can't understand is on how to make it work with the file im copying. If the file im copying is finish, the progress bar should also be 100%. just like the example below,

FileCopy("C:\*.au3", "D:\mydir\*.*")

; Method to copy a folder (with its contents)
DirCreate("C:\new")
FileCopy("C:\old\*.*", "C:\new\")

FileCopy("C:\Temp\*.txt", "C:\Temp\TxtFiles\", 8)
; RIGHT - 'TxtFiles' is now the target directory and the file names are given by the source names

FileCopy("C:\Temp\*.txt", "C:\Temp\TxtFiles\", 9); Flag = 1 + 8 (overwrite + create target directory structure)
; Copy the txt-files from source to target and overwrite target files with same name

and here's the code i found for the progress bar

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)


$Label3 = GUICtrlCreateLabel("", 136, 172, 102, 17, BitOR($SS_CENTER,$SS_BLACKFRAME,$SS_CENTERIMAGE))
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT )
$Label1 = GUICtrlCreateLabel("", 137, 173, 1, 15)
GUICtrlSetBkColor(-1, 0x00ff00)
$Label2 = GUICtrlCreateLabel("Label2", 136, 172, 102, 17, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT )
GUISetState(@SW_SHOW)
for $n = 1 to 100
    controlmove($Form1,"",$Label1,137,173,$n,15)
    GUICtrlSetData($Label2,$n & "%")
    sleep(90)
Next

#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

now, I dont know how to make connect them. hehe! Can someone help me with this pls? ehhe!

Edited by Pies

"Failure is the key to success. So try and try until you succeed!"

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

1) get the full size of the file to copy with FileGetSize

2) start copying the file to the destination

3) whilst the file is copying, repeatedly use FileGetSize on the destination file in a loop (do...until)

4) whilst looping, set the progress bar as the current file size divided by the full file size multiplied by 100.

[EDIT] oh, and use GUICtrlCreateProgress rather than convoluting from labels.

Edited by andybiochem

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

1) get the full size of the file to copy with FileGetSize

2) start copying the file to the destination

3) whilst the file is copying, repeatedly use FileGetSize on the destination file in a loop (do...until)

4) whilst looping, set the progress bar as the current file size divided by the full file size multiplied by 100.

[EDIT] oh, and use GUICtrlCreateProgress rather than convoluting from labels.

Thanks andy. I appreciate your help.

But I didn't understand any of those. T_T

Edited by Pies

"Failure is the key to success. So try and try until you succeed!"

Share this post


Link to post
Share on other sites

And for the record, please refrain from making your thread titles in all caps please.

YELLING ABOUT YOUR PROBLEMS IS ENTIRELY UNNECESSARY AND CAPSLOCK IS NOT CRUISE CONTROL FOR COOL

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

And for the record, please refrain from making your thread titles in all caps please.

YELLING ABOUT YOUR PROBLEMS IS ENTIRELY UNNECESSARY AND CAPSLOCK IS NOT CRUISE CONTROL FOR COOL

Ehehe! i'm sorry for that then. Calm down sorry, anyway, there is something I wanna know. I found Mr.Creator's "Copy with progress" sourcecode. And I wanna know if it is possible to just write the destination of the folder i want to copy if the program that im going to run is in the same folder. For example, the "Copy with progress" is inside the "Desktop folder" and I want to copy the folder named "Source" which is also inside the "Desktop folder", how am I going to write the code which is something like

_CopyWithProgress( "\Source", "C:\Documents and Settings\McPisces\Program Files\Destination", 1)

Instead of writing all the path of the "Source folder" like this

_CopyWithProgress("C:\Documents and Settings\McPisces\Desktop\Source", "C:\Documents and Settings\McPisces\Program Files\Destination", 1)
Edited by Pies

"Failure is the key to success. So try and try until you succeed!"

Share this post


Link to post
Share on other sites

_CopyWithProgress(@scriptdir &  "\Source", "C:\Documents and Settings\McPisces\Program Files\Destination", 1)

but .\ is subject to variable working folder assignment


f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites

Hahhahaha! Problem has now been resolved! Thanks guys!


"Failure is the key to success. So try and try until you succeed!"

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