Página 1 de 1

Mostrar progreso de transferencia

Publicado: 15 Dic 2013, 10:29
por PDF
Buenas

Vengo teniendo una gran duda en autoit con respecto a la transferencia de archivos (copiar, mover, eliminar). Autoit puede realizar estas operaciones, pero como hago para mostrar el progreso de la transferencia en control progress?. Es decir, en un script copiar un archivo de 100 mb de una carpeta a otra, como hago para recuperar la información del progreso de copiado?

Gracias de antemano a todos :smt002

Re: Mostrar progreso de transferencia

Publicado: 15 Dic 2013, 16:40
por Dany
Hola. puedes usar esta UDF.

http://www.autoitscript.com/forum/topic ... -copy-udf/

saludos

Re: Mostrar progreso de transferencia

Publicado: 15 Dic 2013, 20:06
por PDF
Gracias Dany por tu ágil respuesta.

Estaba trabajando en un proyecto para crear una copia de seguridad y me surgió esta duda. Esta UDF me funciona perfecto. Es posible mostrar el progreso de la copia.

Pero me surgió otra duda, las librerias de windows no contienen alguna de estas funciones?.Mi idea era hacerlo lo mas compacto posible, que no contenga muchos archivos 'propios' sino utilizar los de Windows.

Cuando acabe con el mismo comparto código en el foro :smt024

Saludos ..

Re: Mostrar progreso de transferencia

Publicado: 15 Dic 2013, 21:00
por Dany
Pues Puedes Hacerlo por el con SHFileOperation.

Código: Seleccionar todo

Global Const $FO_MOVE                 = 0x0001
Global Const $FO_COPY                 = 0x0002
Global Const $FO_DELETE           = 0x0003
Global Const $FO_RENAME           = 0x0004

Global Const $FOF_MULTIDESTFILES        = 0x0001
Global Const $FOF_CONFIRMMOUSE      = 0x0002
Global Const $FOF_SILENT                = 0x0004
Global Const $FOF_RENAMEONCOLLISION  = 0x0008
Global Const $FOF_NOCONFIRMATION        = 0x0010
Global Const $FOF_WANTMAPPINGHANDLE  = 0x0020
Global Const $FOF_ALLOWUNDO       = 0x0040
Global Const $FOF_FILESONLY       = 0x0080
Global Const $FOF_SIMPLEPROGRESS        = 0x0100
Global Const $FOF_NOCONFIRMMKDIR        = 0x0200
Global Const $FOF_NOERRORUI       = 0x0400
Global Const $FOF_NOCOPYSECURITYATTRIBS = 0x0800
Global Const $FOF_NORECURSION         = 0x1000
Global Const $FOF_NO_CONNECTED_ELEMENTS = 0x2000
Global Const $FOF_WANTNUKEWARNING     = 0x4000
Global Const $FOF_NORECURSEREPARSE  = 0x8000

Func _CopyWithProgress($sFrom, $sTo)
    Local $SHFILEOPSTRUCT
    Local $pFrom
    Local $pTo
    Local $aDllRet
    Local $nError = 0
    Local $i

    $SHFILEOPSTRUCT = DllStructCreate("align 1;hwnd;uint;ptr;ptr;ushort;bool;ptr;ptr")
    If @error Then Return False
; hwnd
    DllStructSetData($SHFILEOPSTRUCT, 1, 0)
; wFunc
    DllStructSetData($SHFILEOPSTRUCT, 2, $FO_COPY)
; pFrom
    $pFrom = DllStructCreate("char[" & StringLen($sFrom)+2 & "]")
; pFrom will now be null-terminated at StringLen($sFrom)+1
    DllStructSetData($pFrom, 1, $sFrom)
    For $i = 1 To StringLen($sFrom)+2
        If DllStructGetData($pFrom, 1, $i) = 10 Then DllStructSetData($pFrom, 1, 0, $i)
    Next
; We need a second null at the end
    DllStructSetData($pFrom, 1, 0, StringLen($sFrom)+2)
    DllStructSetData($SHFILEOPSTRUCT, 3, DllStructGetPtr($pFrom))
; pTo
    $pTo = DllStructCreate("char[" & StringLen($sTo)+2 & "]")
; pTo will now be null-terminated at StringLen($sTo)+1
    DllStructSetData($pTo, 1, $sTo)
; We need a second null at the end
    DllStructSetData($pTo, 1, 0, StringLen($sTo)+2)
    DllStructSetData($SHFILEOPSTRUCT, 4, DllStructGetPtr($pTo))
; fFlags
    DllStructSetData($SHFILEOPSTRUCT, 5, BitOR($FOF_NOCONFIRMMKDIR, _
        $FOF_NOCONFIRMATION, _
        $FOF_NOERRORUI))
; fAnyOperationsAborted
    DllStructSetData($SHFILEOPSTRUCT, 6, 0)
; hNameMappings
    DllStructSetData($SHFILEOPSTRUCT, 7, 0)
; lpszProgressTitle
    DllStructSetData($SHFILEOPSTRUCT, 8, 0)
    $aDllRet = DllCall("shell32.dll", "int", "SHFileOperation", "ptr", DllStructGetPtr($SHFILEOPSTRUCT))
    If @error Or $aDllRet[0] <> 0 Then
        $aDllRet = DllCall("kernel32.dll", "long", "GetLastError")
        If Not @error Then $nError = $aDllRet[0]
    EndIf
    Dim $aborted = DllStructGetData($SHFILEOPSTRUCT, 6)
    DllStructDelete($pFrom)
    DllStructDelete($pTo)
    DllStructDelete($SHFILEOPSTRUCT)
    If $nError <> 0 Then
        SetError($nError)
        Return False
    elseif $aborted Then
        Return False
    EndIf
    Return True
EndFunc

Func DllStructDelete(ByRef $vStruct)
    $vStruct = ""
EndFunc




;Llamada
_CopyWithProgress("D:\Softwares","C:\Documents and Settings\Dark\Escritorio\")



Saludos