teknosjef Posted August 29, 2011 Posted August 29, 2011 Hi.I`m new at this forum. Therefore I will pologize if there are many answers about this theme. But i have a problem.I have made a script for copying a P2-card (videocard) from a cardreader to a server. And it works OK. But the students ask for a progress bar with time left of copying. And I tried to implement some new lines in the script from ;Define source and target (line 56).Then I got the problem. For me, it seems that Win7 set the size of destination when xcopy start copying the last file. Therefor the script told me that the Copy was finnish when it starts copying the last clip.Is there a way around it? A metode there will give me the right time and percents? This is the script: ;=====================================================; Copying P" card to server;=====================================================;=====================================================; Versjon 2.1; HVO amf; Autor: Reidulf Botn;200910;=====================================================#include <GuiConstantsEx.au3>#include <Date.au3>#include <WindowsConstants.au3>;Checking if the server is mapped.If DriveMapGet("P:") <> ("\\media\P2\P2_H10\1TV_H10") Then DriveMapAdd("P:","\\media\P2\P2_H10\1TV_H10") ;MsgBox(0,"P2","Mapper server") Else EndIf MsgBox(0,"Start","Sett inn kortet");Checking if there is a card in the readerIf FileExists("E:\LASTCLIP.TXT") Then ;Asking for input$mappenavn = InputBox("Navn","Skriv inn navn på saken", ""," M")If @error = 1 ThenMsgBox(0,"Cancel","Ikke bruk Cancel" & @LF & "Prøv på nytt")ExitEndIf$initial = InputBox("Initialer","Skriv inn initialene dine", ""," M")If @error = 1 Then MsgBox(0,"Cancel","Ikke bruk Cancel" & @LF & "Prøv på nytt")ExitEndIf ;writing error at screen Else MsgBox(0,"Feilmelding","Sett inn kortet skikkelig") EndIf ;making folders at serverDirCreate("P:\" & $mappenavn & $initial & _DateTimeFormat( _NowCalc(),2))$dir = ("P:\" & $mappenavn & $initial & _DateTimeFormat( _NowCalc(),2)) Sleep(1000);Define source and target$source = "E:\"$dest = $sdir;size of source and target$ssize = DirGetSize($source)$dsize = DirGetSize($dest)if $dsize < 0 then $dsize = 0EndIf;Staring prosess bar and set it to 0ProgressOn("Kopierer filer ...", "", "0 %")ProgressSet(0, "Kalkulerer kopieringstid...")Sleep(1000) ; Starting timer and XCOPY$tbegin = TimerInit()Run(@ComSpec & " /c xcopy /y /e " & $source & "*.* " & $dest, "", @SW_HIDE)For $percent = 0 to 100 $copied = DirGetSize($dest) - $dsize ;estimating how much is copied $percent = Round(($copied/$ssize),2) * 100 ; percent copied $tdiff = TimerDiff($tbegin) ; time difference from start copying $tmin = Round(((100/$percent) -1) * ($tdiff/60000)) ; resttime in minutes $tsec = Round(((100/$percent) -1) * ($tdiff/1000)) ;resttime in seconds ;If remaining time is less than one minute, prosses bar will show the time in seconds If $tsec < 60 Then $tdisplay = " Cirka " & $tsec & " sekund igjen" Else $tdisplay = " Cirka " & $tmin & " minutter igjen" EndIf ProgressSet( $percent, "Prosent kopiert: " & $percent & " %" & @LF & $tdisplay) Sleep(1000)NextProgressSet(100, "Ferdig", "")Sleep(1500)ProgressOff()Exit
bogQ Posted August 29, 2011 Posted August 29, 2011 (edited) i think that your looking for this if im not wrong (dono if itl work for win7, on xp i don`t have problems) http://msdn.microsoft.com/en-us/library/aa363854(v=VS.85).aspxhttp://msdn.microsoft.com/en-us/library/aa363852(v=VS.85).aspx <--- click it Edited August 29, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
Legacy99 Posted August 29, 2011 Posted August 29, 2011 Yep, try this, just tested on Win7 X64 _FileCopy($fromFile, $tofile) Local $FOF_RESPOND_YES = 16 Local $FOF_SIMPLEPROGRESS = 256 $winShell = ObjCreate("shell.application") $winShell.namespace($tofile).CopyHere($fromFile, $FOF_RESPOND_YES)
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