Sign in to follow this  
Followers 0
mehrdad39

File copy with progress bar

5 posts in this topic

I have a script that moves a file from USB to root and copies a file from desktop back to the USB. It all works fine but I would like to add a progress bar to show the user when as the copying is going and when the process is finished. I have looked at many of the examples and tried many of them without success (lots of errors). Any suggestion is appreciated. Also, I am still learning!

Thanks

Mehrdad

#include <GUIConstantsEx.au3>
#include <Process.au3>
#include <Misc.au3>         

Opt('MustDeclareVars', 1)

                if _Singleton("duplicate",1) = 0 Then
                    Exit
                EndIf

Menu()
        
Func Menu()
    Local $Finish, $Continue, $Cancel, $font, $msg, $var, $Rootdr, $drive
    

    GUICreate("DVR Update", 400, 150)

    GUISetFont(11, 800, 4, $font) 
    GUICtrlCreateLabel("DVR Restore and Recovery Update Utility", 55, 15)
    GUISetFont(8.5, 400, $font) 
    GUICtrlCreateLabel("WARNING - The Flash drive will now be updated.  DO NOT INTERRUP the update process.  DO NOT REMOVE the USB flash drive until the process is complete and the light on the flash drive has stopped flashing.  This process may take up to five (5) minutes.  To start the update, click on Continue.  To exit without updating, click on Cancel", 20, 40, 360, 70)

    $Continue = GUICtrlCreateButton("Continue", 120, 120, 70, 25)
    $Cancel = GUICtrlCreateButton("Cancel", 210, 120, 70, 25)
;   $Finish = GUICtrlCreateButton("Finish", 250, 120, 70, 25)
    $Rootdr = "c:\"

    GUISetState()

    ; Start the GUI
    While 1
        $msg = GUIGetMsg()
            Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop

                Case $msg = $Continue
        
                $var = DriveGetDrive( "removable" )
                    If NOT @error Then
                         For $i = 1 to $var[0]
                          $drive = $var[$i]     

                        If FileExists(@DesktopDir & "\update.wim") Then 

                                filemove($drive & "\recovery.wim", $Rootdr & "\oldrecovery.wim", 1)
                                FileCopy(@DesktopDir & "\update.wim", $drive & "\recovery.wim", 1)
                                
                            MsgBox(4160, "", "The update process is now complete.  Disconnect and remove the USB flash drive properly from Windows.  Click 'OK' to exit")
                            
                        Else
                            MsgBox(4112, "Error", "The Update file is not located on the Desktop.  Please copy or download the Update file to the desktop")
                          EndIf
                       Next
                    EndIf       
    
                    Exit

                    Case $msg = $Cancel
                    Exit    
        EndSelect
    WEnd
EndFunc

Share this post


Link to post
Share on other sites



hello, i have an idea but dont know if its codeable:

before start moving or copying, read size of sourcefile.

during moving / copying read (loop) size of targetfile,

compare it with source-size an then calculate and set progressbar.

Share this post


Link to post
Share on other sites

Maybe this thread.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thanks Martin,

I had tried to use the script in my GUI before I posted and that was where I was getting a lot of errors. I am not sure where in my script I need to utilize the suggested script. As shown in my GUI script there are two file copy precesses. One to copy from USB to HDD and then from the desktop to the USB. I had problem getting the functions recognized or executed. Do you have any suggestions how I can merge the suggested script into my script?

Thanks

Mehrdad

Share this post


Link to post
Share on other sites

The problem I am having is that I have multiple functions that are inside of each other and am not able to find information on how to use functions inside other functions. Any ideas?

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