Jump to content

Progress of Filecopy in a GUI


Recommended Posts

Found some interesting code for show the progress of filecopy.

When I run the code in "normal" script it works fine.

Tried to use the code in a GUI, here nothing happens.

Is it possible to use this code in a GUI?

Do I have to do some changes?

Is there some other stuff to show the copy progress in a GUI?

Thank you

;~ 4 Do not display a progress dialog box.  
;~ 8 Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.  
;~ 16 Respond with "Yes to All" for any dialog box that is displayed.  
;~ 64 Preserve undo information, if possible. 
;~ 128 Perform the operation on files only if a wildcard file name (*.*) is specified.  
;~ 256 Display a progress dialog box but do not show the file names.  
;~ 512 Do not confirm the creation of a new directory if the operation requires one to be created.  
;~ 1024 Do not display a user interface if an error occurs.  
;~ 2048 Version 4.71. Do not copy the security attributes of the file. 
;~ 4096 Only operate in the local directory. Don't operate recursively into subdirectories. 
;~ 9182 Version 5.0. Do not copy connected files as a group. Only copy the specified files.  

_FileCopy("C:\Installed Apps\Patches\WindowsXP-KB835935-SP2-ENU.exe","C:\temp")

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

Found the code here:

Link to comment
Share on other sites

Found some interesting code for show the progress of filecopy.

When I run the code in "normal" script it works fine.

Tried to use the code in a GUI, here nothing happens.

Is it possible to use this code in a GUI?

Do I have to do some changes?

Is there some other stuff to show the copy progress in a GUI?

Thank you

;~ 4 Do not display a progress dialog box.  
;~ 8 Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.  
;~ 16 Respond with "Yes to All" for any dialog box that is displayed.  
;~ 64 Preserve undo information, if possible. 
;~ 128 Perform the operation on files only if a wildcard file name (*.*) is specified.  
;~ 256 Display a progress dialog box but do not show the file names.  
;~ 512 Do not confirm the creation of a new directory if the operation requires one to be created.  
;~ 1024 Do not display a user interface if an error occurs.  
;~ 2048 Version 4.71. Do not copy the security attributes of the file. 
;~ 4096 Only operate in the local directory. Don't operate recursively into subdirectories. 
;~ 9182 Version 5.0. Do not copy connected files as a group. Only copy the specified files.  

_FileCopy("C:\Installed Apps\Patches\WindowsXP-KB835935-SP2-ENU.exe","C:\temp")

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

Found the code here:

I'd have to see how your trying to include it, the code you have simply uses a built in windows function to copy a file and uses the windows style file copy progress dialogue.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("Form3", 405, 294, 302, 218)
$Button1 = GUICtrlCreateButton("Copy File", 135, 95, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _FileCopy("C:\Installed Apps\Patches\WindowsXP-KB835935-SP2-ENU.exe","C:\temp")
    EndSwitch
WEnd





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

I want to use a GUI with some Checkboxes.

Later the script should check the checkboxes and copy one or more files.

If possible I would use the windows copy, cause the code with a few lines looked easy for me to implement, but wasn't. ;-)

If there are other progress bars to use with the filecopy function I would use on of them too.

#RequireAdmin
#include <GuiConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <file.au3>
#include <array.au3>


$ScriptName                 = "Inhaltscenterbibliotheken Copy Tool 2012"

$ButtonBreite               = 100
$ButtonHoehe                = 30
$breite                     = 520
$hoehe                      = 420
$font                       = "Tahoma"
$PosLabel                   = 15
$PosLinks                   = 10
$PosRechts                  = 200



$server = "\\EMI-S4\"

; Quelle
$quelle = $server & "Inventor\Inventor_2012\InhaltsCenterBibliotheken\"

; Ziel
If (@OSVersion = "WIN_XP") Then
    $ziel   = @AppDataCommonDir & "\Autodesk\Inventor 2012\Content Center\Libraries\"
EndIf

If (@OSVersion = "WIN_VISTA") OR (@OSVersion = "WIN_7") Then
    $ziel   = @AppDataCommonDir & "\Autodesk\Inventor 2012\Content Center\Libraries\"
EndIf

; Bibliotheken
$file1  = "AI2012_Inventor ANSI.idcl"
$file2  = "AI2012_Inventor DIN.idcl"
$file3  = "AI2012_Inventor Feature.idcl"
$file4  = "AI2012_Inventor ISO.idcl"
$file5  = "AI2012_Inventor JIS & GB.idcl"
$file6  = "AI2012_Inventor Mold Metric.idcl"
$file7  = "AI2012_Inventor Parker.idcl"
$file8  = "AI2012_Inventor Routed Systems.idcl"
$file9  = "AI2012_Inventor Sheet Metal.idcl"




; GUI
GuiCreate($ScriptName, $breite, $hoehe)


; Text
GUISetFont (10, 400, 0, $font)
GUICtrlCreateLabel ("Tool zum Kopieren/Löschen der Inhaltcenter Bibliotheken für Inventor 2012", 10, $PosLabel)
$PosLabel = $PosLabel+25
GUICtrlCreateLabel ("Bibliotheken sind zu finden unter:", 10, $PosLabel)
$PosLabel = $PosLabel+20
GUICtrlCreateLabel ($ziel, 10, $PosLabel)

; Quelle
GUISetFont (10, 400, 0, $font)
$PosLabel = $PosLabel+30
GUICtrlCreateLabel ("Inhaltscenter Bibliothek(en) aus- oder abwählen:", $PosLinks, $PosLabel)

; Checkboxen
GUISetFont (9, 400, "", $font)
$PosLinks = $PosLinks + 15
$PosLabel = $PosLabel+20
$CheckBox1 = GUICtrlCreateCheckbox ("ANSI", $PosLinks, $PosLabel)
If (FileExists ($ziel & $file1)) Then
    GUICtrlSetState(-1, $GUI_CHECKED)
Else
  GUICtrlSetState(-1, $GUI_UNCHECKED)
EndIf

$PosLabel = $PosLabel+20
$CheckBox2 = GUICtrlCreateCheckbox ("DIN", $PosLinks, $PosLabel)
If (FileExists ($ziel & $file2)) Then
    GUICtrlSetState(-1, $GUI_CHECKED)
Else
  GUICtrlSetState(-1, $GUI_UNCHECKED)
EndIf

$PosLabel = $PosLabel+20
$CheckBox3 = GUICtrlCreateCheckbox ("Feature", $PosLinks, $PosLabel)
If (FileExists ($ziel & $file3)) Then
    GUICtrlSetState(-1, $GUI_CHECKED)
Else
  GUICtrlSetState(-1, $GUI_UNCHECKED)
EndIf

$PosLabel = $PosLabel+20
$CheckBox4 = GUICtrlCreateCheckbox ("ISO", $PosLinks, $PosLabel)
If (FileExists ($ziel & $file4)) Then
    GUICtrlSetState(-1, $GUI_CHECKED)
Else
  GUICtrlSetState(-1, $GUI_UNCHECKED)
EndIf

$PosLabel = $PosLabel+20
$CheckBox5 = GUICtrlCreateCheckbox ("JIS & GB", $PosLinks, $PosLabel)
If (FileExists ($ziel & $file5)) Then
    GUICtrlSetState(-1, $GUI_CHECKED)
Else
  GUICtrlSetState(-1, $GUI_UNCHECKED)
EndIf

$PosLabel = $PosLabel+20
$CheckBox6 = GUICtrlCreateCheckbox ("Mold Metric", $PosLinks, $PosLabel)
If (FileExists ($ziel & $file6)) Then
    GUICtrlSetState(-1, $GUI_CHECKED)
Else
  GUICtrlSetState(-1, $GUI_UNCHECKED)
EndIf

$PosLabel = $PosLabel+20
$CheckBox7 = GUICtrlCreateCheckbox ("Parker", $PosLinks, $PosLabel)
If (FileExists ($ziel & $file7)) Then
    GUICtrlSetState(-1, $GUI_CHECKED)
Else
  GUICtrlSetState(-1, $GUI_UNCHECKED)
EndIf

$PosLabel = $PosLabel+20
$CheckBox8 = GUICtrlCreateCheckbox ("Routed Systems", $PosLinks, $PosLabel)
If (FileExists ($ziel & $file8)) Then
    GUICtrlSetState(-1, $GUI_CHECKED)
Else
  GUICtrlSetState(-1, $GUI_UNCHECKED)
EndIf

$PosLabel = $PosLabel+20
$CheckBox9 = GUICtrlCreateCheckbox ("Sheet Metal", $PosLinks, $PosLabel)
If (FileExists ($ziel & $file9)) Then
    GUICtrlSetState(-1, $GUI_CHECKED)
Else
  GUICtrlSetState(-1, $GUI_UNCHECKED)
EndIf




; Buttons
$ButtonLos = GuiCtrlCreateButton("&Los", (($breite/3)-($ButtonBreite/2)), $hoehe-70, $ButtonBreite, $ButtonHoehe)
GUICtrlSetTip(-1, "Los gehts")
$ButtonExit = GuiCtrlCreateButton("&Ende", (($breite/3)+($breite/3)-($ButtonBreite/2)), $hoehe-70, $ButtonBreite, $ButtonHoehe)
GUICtrlSetTip(-1, "Programm beenden")



; Show the GUI
GuiSetState ()

While 1
    $msg = GUIGetMsg()
    Select

        Case $msg = $ButtonLos
            KopiereFile()

        Case $msg = $GUI_EVENT_CLOSE Or $msg = $ButtonExit
          Exit

    EndSelect
WEnd

GUIDelete()




; ##################
; #   Funktionen   #
; ##################

Func KopiereFile()

    If GUICtrlRead($CheckBox1) = $GUI_CHECKED Then
        _FileCopy($quelle & $file1, $ziel & $file1)
    Else
        FileDelete ($ziel & $file1)
    EndIf

    ; Here should follow the other checks for the checkboxes

EndFunc



Func _FileCopy($quelle, $ziel)
    Local $FOF_RESPOND_YES = 16
    Local $FOF_SIMPLEPROGRESS = 256
    $winShell = ObjCreate("shell.application")
  $winShell.namespace($ziel).CopyHere($quelle, $FOF_RESPOND_YES)
EndFunc
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...