fortschritt bei fileinstall als progressbar anzeigen

  • Als Ersatz für FileCopy könnte folgende Variante dienen:

    [autoit]

    #include <GUIConstants.au3>

    [/autoit][autoit][/autoit][autoit]

    Opt("GUIOnEventMode", 1)
    $Form1 = GUICreate("Form1", 196, 47, 193, 125)
    $Progress1 = GUICtrlCreateProgress(16, 8, 150, 17)
    GUICtrlSetLimit(-1, 100, 0)
    GUISetState(@SW_SHOW)

    [/autoit][autoit][/autoit][autoit]

    $filesize = 728369152 ; hier die Größe in Byte eintragen
    $buffer = 1024
    AdlibEnable("check",100)

    [/autoit][autoit][/autoit][autoit]

    $in = FileOpen("demo.exe",0)
    $out = FileOpen("demo2.exe",1)
    While 1
    $daten = FileRead($in,$buffer)
    If @error = -1 Then ExitLoop
    FileWrite($out,$daten)
    Wend
    FileClose($in)
    FileClose($out)
    Sleep(5000)

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    Func check()
    GUICtrlSetData($Progress1,Round(100 * FileGetSize("demo2.exe") / $filesize))
    EndFunc

    [/autoit]

    Aber das hilft nicht, wenn man mit FileInstall arbeiten will....

    Zur Nutzung dieses Forum's, ist ein Übersetzer für folgende Begriffe unerlässlich:

    "On-Bort, weier, verscheiden, schädliges, Butten steyling, näckstet, Parr, Porblem, scripe, Kompletenz, harken, manuel zu extramieren, geckukt, würglich, excell, acces oder Compilevorgeng"

  • Ich hab mal aus Spaß Micha_he´s Ansatz aufgegriffen und was daraus gebastelt.
    Das Ergebnis wird dir bei deinem Problem hier wohl nicht wirklich weiterhelfen aber immerhin sollte es funktionieren... ;) :

    Spoiler anzeigen
    [autoit]


    $Quelle = @SystemDir & '\taskmgr.exe'
    $Ziel = "C:\taskmgr.exe"

    [/autoit] [autoit][/autoit] [autoit]

    If _ProgressCopy($Quelle, $Ziel) Then MsgBox(0,"", "Kopiervorgang erfolgreich!")

    [/autoit] [autoit][/autoit] [autoit]

    Func _ProgressCopy($SourceFile, $DestinationFile)
    If Not FileExists($SourceFile) Then Return SetError(1,1,0)
    If $SourceFile == $DestinationFile Then Return SetError(2,2,0)

    #region------------------------------------Declare Variables-------------------------------
    Local $ByteBlock, $Counter
    Local Const $BlockSize = Int(FileGetSize($SourceFile) / 99)
    Local Const $Opt = Opt("GUIOnEventMode", 0)
    Local $OpenHandle = FileOpen($SourceFile, 16)
    Local $WriteHandle = FileOpen($DestinationFile, 26)
    #endregion---------------------------------------------------------------------------------

    If $OpenHandle = -1 Or $WriteHandle = -1 Then Return SetError(3,3,0)

    #region------------------------------------GUI create--------------------------------------
    Local $GUI = GUICreate('', 400, 105, Default, Default, 0x80880000)
    Local $Label1 = GUICtrlCreateLabel($SourceFile, 8, 10)
    Local $Label2 = GUICtrlCreateLabel($DestinationFile, 8, 30)
    Local $Label3 = GUICtrlCreateLabel("0%", 360, 25, 30, 20, 0x2)
    Local $Button = GUICtrlCreateButton("Abbrechen", 160, 75, 80)
    Local $PBar = GUICtrlCreateProgress(8, 50, 384, 20)
    GUISetState()
    #endregion---------------------------------------------------------------------------------

    #region----------------------------------Copy File-----------------------------------------
    Do
    $ByteBlock = FileRead($OpenHandle, $BlockSize)
    If @error Then ExitLoop
    FileWrite($WriteHandle, $ByteBlock)
    $Counter += 1
    GUICtrlSetData($PBar, $Counter)
    GUICtrlSetData($Label3, $Counter & ' %')

    If GUIGetMsg() = $Button Then
    Opt("GUIOnEventMode", $Opt)
    FileClose($OpenHandle)
    FileClose($WriteHandle)
    GUIDelete($GUI)
    FileDelete($DestinationFile)
    Return SetError(4,4,0)
    EndIf

    Sleep(20) ;Bremse - Auskommentieren für maximale Geschwindigkeit
    Until 0
    #endregion---------------------------------------------------------------------------------


    Opt("GUIOnEventMode", $Opt)
    FileClose($OpenHandle)
    FileClose($WriteHandle)
    GUIDelete($GUI)
    Return 1
    EndFunc

    [/autoit]


    Die Sache mit FileInstall wird meiner Meinung nach sowieso nicht funktionieren da das Skript erst weiterarbeiten kann wenn diese Funktion komplett abgeschlossen ist.

    Edit: So das Geschwindigkeitsproblem ist nun auch gelöst - jetzt rennt das Skript auch bei großen Dateien.
    Musste sogar eine Bremse einbauen welche man auskommentieren kann damit man den Kopiervorgang überhaupt mitbekommt.... ;)

    4 Mal editiert, zuletzt von AspirinJunkie (10. Januar 2008 um 10:16)

  • Ich hatte mit bei meinem Test, keine Probleme. Der FileCopy-Ersatz mit ProgressBar-Aktualisierung funktioniert mit einer über 700MB großen Testdatei.
    Ich kann mir das nicht erklären, warum nur 1/4 kopiert werden sollte.

    AspirinJunkie:
    Die Idee mit der Blocksize=FileSize/99 ist natürlich gut !

    Zur Nutzung dieses Forum's, ist ein Übersetzer für folgende Begriffe unerlässlich:

    "On-Bort, weier, verscheiden, schädliges, Butten steyling, näckstet, Parr, Porblem, scripe, Kompletenz, harken, manuel zu extramieren, geckukt, würglich, excell, acces oder Compilevorgeng"

  • Moin,

    AspirinJunkie: :thumbup: sehr gut !
    Mir ist aus versehen etwas Farbe in die Progressbar gekippt. :D

    Spoiler anzeigen
    [autoit]


    $Quelle = @SystemDir & '\taskmgr.exe'
    $Ziel = "C:\taskmgr.exe"

    [/autoit] [autoit][/autoit] [autoit]

    If _ProgressCopy($Quelle, $Ziel) Then MsgBox(0,"", "Kopiervorgang erfolgreich!")

    [/autoit] [autoit][/autoit] [autoit]

    Func _ProgressCopy($SourceFile, $DestinationFile)
    If Not FileExists($SourceFile) Then Return SetError(1,1,0)
    If $SourceFile == $DestinationFile Then Return SetError(2,2,0)

    [/autoit] [autoit][/autoit] [autoit]

    #region------------------------------------Declare Variables-------------------------------
    Local $ByteBlock, $Counter
    Local Const $BlockSize = Int(FileGetSize($SourceFile) / 99)
    Local Const $Opt = Opt("GUIOnEventMode", 0)
    Local $OpenHandle = FileOpen($SourceFile, 16)
    Local $WriteHandle = FileOpen($DestinationFile, 26)
    #endregion---------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    If $OpenHandle = -1 Or $WriteHandle = -1 Then Return SetError(3,3,0)

    [/autoit] [autoit][/autoit] [autoit]

    #region------------------------------------GUI create--------------------------------------
    Local $GUI = GUICreate('', 400, 105, Default, Default, 0x80880000)
    Local $Label1 = GUICtrlCreateLabel($SourceFile, 8, 10)
    Local $Label2 = GUICtrlCreateLabel($DestinationFile, 8, 30)
    Local $Label3 = GUICtrlCreateLabel("0%", 360, 25, 30, 20, 0x2)
    Local $Button = GUICtrlCreateButton("Abbrechen", 160, 75, 80)
    ; Local $PBar = GUICtrlCreateProgress(8, 50, 384, 20)
    GUISetState()
    #endregion---------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    #region----------------------------------Copy File-----------------------------------------
    Do
    $ByteBlock = FileRead($OpenHandle, $BlockSize)
    If @error Then ExitLoop
    FileWrite($WriteHandle, $ByteBlock)
    $Counter += 1
    $xx102 = 8 + ($Counter)*3.75
    $xx103 = Floor($Counter)
    ;GUICtrlSetData($PBar, $Counter)
    $Progress1=GUICtrlCreateLabel("",$xx102, 50, 4, 20)
    If $Counter <60 Then
    $Farbe= Int(256 - (5.12 * $Counter * 2/ 512) * 2.55) *65536 + Int((512 * $Counter * 2 / 256)* 255) + Int(($Counter * 2 / 100 * 255) - 512)
    Elseif $Counter >60 Then
    $Farbe= Int(256 - (($Counter - 60) / 128) * 255) *65536 - int(256 * ($Counter - 60) * 256) + Int((($Counter - 60) / 100 * 255)) - 5052 - Int(($Counter/ 100 * $Counter-30)*2)
    EndIf
    GUICtrlSetBkColor($Progress1, $Farbe)
    GUICtrlSetData($Label3, $Counter & ' %')

    [/autoit] [autoit][/autoit] [autoit]

    If GUIGetMsg() = $Button Then
    Opt("GUIOnEventMode", $Opt)
    FileClose($OpenHandle)
    FileClose($WriteHandle)
    GUIDelete($GUI)
    FileDelete($DestinationFile)
    Return SetError(4,4,0)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Sleep(20) ;Bremse - Auskommentieren für maximale Geschwindigkeit
    Until 0
    #endregion---------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", $Opt)
    FileClose($OpenHandle)
    FileClose($WriteHandle)
    GUIDelete($GUI)
    Return 1
    EndFunc

    [/autoit]

    Gruß
    trallala