Pietka Posted January 16, 2006 Share Posted January 16, 2006 Hi, You helped me once ( especially Ezzetabi ) need help once more. Ihave something like this ( it's ezzetabi code !): $src="c:\intel" $src2="c:\swsetup" _xcopyWithDialog($src, "c:\temp") _xcopyWithDialog2($src2, "c:\temp2") Func _xcopyWithDialog($sStartingDir, $sDestDir, $sSettings = '/i/c/e/d/h/r/y') Local $iPid, $iSDSize, $iODSize If FileExists($sStartingDir) And StringInStr(FileGetAttrib($sStartingDir), 'd') Then $iPid = Run(@comspec & ' /c xcopy "' & $sStartingDir & '" "' & $sDestDir & '" ' & $sSettings) $iSDSize = DirGetSize($sStartingDir) ProgressOn ( "XCopy", "Coping temp please wait...") While ProcessExists($iPid) $iODSize = DirGetSize($sDestDir) ProgressSet(Round(100 * $iODSize / $iSDSize) ) Sleep(100) WEnd ProgressOff( ) Else Return -1 EndIf EndFunc ; ; ; ; ; Func _xcopyWithDialog2($sStartingDir, $sDestDir, $sSettings = '/i/c/e/d/h/r/y') Local $iPid, $iSDSize, $iODSize If FileExists($sStartingDir) And StringInStr(FileGetAttrib($sStartingDir), 'd') Then $iPid = Run(@comspec & ' /c xcopy "' & $sStartingDir & '" "' & $sDestDir & '" ' & $sSettings) $iSDSize = DirGetSize($sStartingDir) ProgressOn ( "XCopy", "Coping...") While ProcessExists($iPid) $iODSize = DirGetSize($sDestDir) ProgressSet(Round(100 * $iODSize / $iSDSize) ) Sleep(100) WEnd ProgressOff( ) Else Return -1 EndIf EndFunc In progress bar window I want to display names of files which are being copied - do You know how to make it ? Regards Pietka Link to comment Share on other sites More sharing options...
ChrisL Posted January 16, 2006 Share Posted January 16, 2006 (edited) In progress bar window I want to display names of files which are being copied - do You know how to make it ? Regards Pietka Yes I do but a different way to that, I wrote this.. You will need to use beta version for it though Change this line to the directories you want to copy, Progresscopy("Source path","Destination") so like Progresscopy("d:\kiosk","d:\backup2") Also If you wanted to you can compile the whole script to prcopy.exe and call it with comand line options i.e. prcopy d:\kiosk d:\backup2 or include it in your own script #include<prcopy.au3> and call it as a function its up to you expandcollapse popup#include-once #include <GUIConstants.au3> Global $Run1 = 0, $tosearch, $OverallQty, $Overall, $source, $overallpercent, $Progress0Text, $progressbar1, $Progress1Text, $progressbar2, $Progress2Text Progresscopy("Source path","Destination") If $cmdline[0] = 2 Then $StartDir = $cmdline[1] $EndDir = $cmdline[2] ProgressCopy ($StartDir,$EndDir) EndIf Func ProgressCopy($current,$destination) ;FirstTimeRun Get original DirSize and set up Gui If $Run1 = 0 then $Source = $Current If StringRight($current, 1) = '\' Then $current = StringtrimRight( $current, 1 ) If StringRight($destination, 1) = '\' Then $destination = StringtrimRight( $destination, 1 ) $tosearch = $current $Overall = DirGetSize ($tosearch, 1) $OverallQty = $Overall[1] $Gui = GUICreate("Copying Files",420,100, -1,-1,-1, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) $Progress0Text = GUICtrlCreateLabel ( "Please Wait", 10, 5 , 400 , 20, $SS_LEFTNOWORDWRAP ) $progressbar1 = GUICtrlCreateProgress (10,20,400,20) GUICtrlSetColor(-1,32250) $Progress1Text = GUICtrlCreateLabel ( "", 10, 44 , 400 , 20, $SS_LEFTNOWORDWRAP ) $progressbar2 = GUICtrlCreateProgress (10,60,400,20, $PBS_SMOOTH ) $Progress2Text = GUICtrlCreateLabel ( "", 10, 82 , 400 , 20, $SS_LEFTNOWORDWRAP ) GUISetFont (10, 600 ) $Progress2Text2 = GUICtrlCreateLabel ( "", 150, 62 , 400 , 20 ) GUICtrlSetColor(-1,0xffffff); not working with Windows XP Style if not using windows classic style GUISetState (@SW_Show) GUICtrlSetData ($progress1Text,"Working Directory " & $tosearch) $Run1 = 1 Endif $Size = DirGetSize ($current, 3) $Qty = $Size[1] Local $search = FileFindFirstFile($current & "\*.*") While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file)<1 Then ExitLoop If not StringInStr(FileGetAttrib($current & "\" & $file),"D") And ( $file <> "." Or $file <> ".." ) then $Qty -=1 $LocalPercent =100 -( ($Qty / $Size[1]) * 100) $OverallQty -=1 $OverallPercent =100 -( ($OverallQty / $Overall[1]) * 100) GUICtrlSetData ($progress0Text, "Total Progress " & Int ( $OverallPercent ) & "% completed") GUICtrlSetData ($progressbar1, $OverallPercent) GUICtrlSetData ($progressbar2, $LocalPercent) GUICtrlSetData ($progress2Text,"Copying File " & $file) FileCopy($current & "\" & $file, $destination & StringTrimLeft ($Current, Stringlen ($Source)) & "\" & $File) FileSetAttrib ($destination & StringTrimLeft ($Current, Stringlen ($Source)) & "\" & $File, "-R") Endif If StringInStr(FileGetAttrib($current & "\" & $file),"D") And ( $file <> "." Or $file <> ".." ) Then DirCreate ($destination & StringTrimLeft ($Current, Stringlen ($Source))& "\" & $File) FileSetAttrib ($destination & StringTrimLeft ($Current, Stringlen ($Source))& "\" & $File, "-R") GUICtrlSetData ($progress1Text, $current & "\" & $file) ProgressCopy($current & "\" & $file,$destination) Endif WEnd FileClose($search) ;when overall percent = 100 set end gui text, delete gui and reset run1 to 0 If $OverallPercent = 100 then GUICtrlSetData ($progress0Text, "Total Progress 100% completed") GUICtrlSetData ($progressbar1, 100) GUICtrlSetData ($progressbar2, 100) GUICtrlSetData ($progress2Text,"Done!") Sleep (2000) GUIDelete($Gui) $Run1 = 0 Endif EndFunc Edited January 16, 2006 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now