Sign in to follow this  
Followers 0
JimC

Progress on Copy

6 posts in this topic

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.

Share this post


Link to post
Share on other sites



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 ?

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

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 .

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