JimC Posted August 1, 2007 Share Posted August 1, 2007 I am having a hard time instituing a progress bar while copy an xp cd to the hard drive. The folowing two functions are used to do the copy. I would like to show a progress bar while the copy is in progress: Here are the two functions: Func FindCD() ; Check if Win XP CD in CDRom Local $drvs, $i $drvs = DriveGetDrive("CDROM") If Not @error Then For $i = 1 To $drvs[0] If DriveStatus($drvs[$i] & "\") = "READY" Then If FileExists($drvs[$i] & "\WIN51IP.SP2") Then $cddrive = $drvs[$i] EndIf EndIf Next EndIf EndFunc Func Copy() ; Copy Win XP CD files to HDD $message = GUICtrlCreateLabel('Copying Windows XP Files To HardDrive.', 10, 405, 400, 20) DirCopy($cddrive, $xpcd, 1) DirCreate(@AppDataDir & '\' & $title) IniWrite(@AppDataDir & '\' & $title & '\Settings.ini', 'Location', 'Project Folder', $xpcd) GUICtrlDelete($message) EndFunc I would like to incorporate something like this function excpet I would like to get the size of the cd and display a progressbar of how the copy is going. $FileUrl = "http://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.2.3.14-beta-setup.exe" $FileSize = InetGetSize($FileUrl) $FileName = StringSplit($FileUrl, "/") $FileName = $FileName[$FileName[0]] InetGet($FileUrl,@scriptdir & "\" & $FileName, 1, 1) HotKeySet("{ESC}", "_InetGetAbort") ProgressOn("Download progress for "&$FileName, "", "0%") While @InetGetActive $Prog = Int((100 * @InetGetBytesRead) / $FileSize) ProgressSet($prog, @InetGetBytesRead & "/" & $FileSize & " bytes", "Downloading "&$FileName) Sleep(250) WEnd Func _InetGetAbort() InetGet("abort") EndFunc ;==> _InetGetAbort() Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
lod3n Posted August 1, 2007 Share Posted August 1, 2007 ezzetabi has a fantastic UDF called _CopyDirWithProgresshttp://www.autoitscript.com/forum/index.php?showtopic=11313 [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
JimC Posted August 1, 2007 Author Share Posted August 1, 2007 CopyWithCustomProgress($cddrive, $xpcd) previous funtions obtain the cd drive letter that houses xp cd ($cddrive) as well as the destination that is housed in $xpcd I declare this function Func CopyWithCustomProgress($SourcePath, $DestPath, $Replace=0) If Not FileExists($SourcePath) Then Return SetError(1, 0, -1) If Not StringInStr(FileGetAttrib($DestPath), "D") And Not DirCreate($DestPath) Then Return SetError(2, 0, "") If $Replace <> 0 And $Replace <> 1 Then SetError(3, 0, "") Local $PathName = StringRegExpReplace($SourcePath, "^.*\\", "") Local $Progress=0, $Counter, $ReadySize, $MidlePath, $Ready, $TimeRemained Local $CurrentFilePath, $CurrentFileName, $CurrentFilePathName, $CurrentParentDirName ProgressOn("Copy Files...", "Copy: " & $PathName, "Getting dir structure" & @LF & "Please wait...") Local $TotalDirSize = DirGetSize($SourcePath) Local $FilesArr = _FileListToArrayEx($SourcePath) Local $FilesCount = UBound($FilesArr)-1 Local $ProgressStep = 100 / $FilesCount If IsArray($FilesArr) Then For $i = 1 To UBound($FilesArr)-1 $CurrentFilePath = $FilesArr[$i] $CurrentFileName = StringRegExpReplace($CurrentFilePath, "^.*\\", "") $CurrentFilePathName = StringReplace($CurrentFilePath, $SourcePath & "\", "") $CurrentParentDirName = _GetParentDirName($CurrentFilePath) $Progress += $ProgressStep $Counter += 1 $ReadySize = FileGetSize($CurrentFilePath) $MidlePath = _GetMidlePath($CurrentFilePath) $Ready = $Counter & "/" & $FilesCount $TimeRemained = _GetTimeRemained($TotalDirSize, $ReadySize, $FilesCount, $Counter) ProgressSet($Progress, 'Copy... from "' & $CurrentParentDirName & '" to "' & $CurrentParentDirName & '"' & @LF & _ $MidlePath & @LF & "Approximately Remained Time: " & $TimeRemained, "Ready: " & $Ready) FileCopy($CurrentFilePath, $DestPath & "\" & $CurrentFilePathName, 8+$Replace) Next EndIf ProgressOff() EndFunc I get the message Copy: d: Getting dir structure Please wait Nothing happens .. Any ideas what to do to fix ? Link to comment Share on other sites More sharing options...
lod3n Posted August 1, 2007 Share Posted August 1, 2007 (edited) Are you running this from within Scite? If not, do so. It's included with the AutoIt installation. There might be an error you're not seeing. Are you sure all of the functions referenced in your custom function are available? Every function call that starts with a _ should be either there in your script or referenced with an #include Edited August 1, 2007 by lod3n [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
MHz Posted August 1, 2007 Share Posted August 1, 2007 ezzetabi has a fantastic UDF called _CopyDirWithProgresshttp://www.autoitscript.com/forum/index.php?showtopic=11313@JimCPost in same thread by myself here for using CopyHere. JdeB posted here about CopyHere in little more detail in an earlier post.CopyHere is a easier solution if it suits. Link to comment Share on other sites More sharing options...
JimC Posted August 3, 2007 Author Share Posted August 3, 2007 Used it and it works great.... Next part im working on is reading in the hotfixes into and array, sorting the list to ensure the y execute in proper order, and display countdown of how many hotfixes are left to run . 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