Moin ich hab bissel was anderes geschrieben so sieht es aus
[autoit]#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.0.0
Author: myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
#include <GUIConstants.au3>
#include <Date.au3>
#include <file.au3>
#include <_LOG.au3>
#include <Inet.au3>
#include <Array.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <GUIConstantsEx.au3>
#include <windowsconstants.au3>
opt("TrayIconDebug",1)
Global $Secs, $Mins, $Hour, $Time ,$Start
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=C:\Users\Matthias\Desktop\Mein Programm\Download_GUI.kxf
$Download_GUI = GUICreate("Download in Bearbeitung", 400, 425, 192, 123)
GUISetFont(15, 400, 0, "MS Sans Serif")
GUISetBkColor(0x000000)
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Download_GUIMinimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Download_GUIRestore")
$Avi1 = GUICtrlCreateAvi("C:\Users\Matthias\Desktop\Mein Programm\download.avi", -1, 64, 16, 272, 60)
GUICtrlSetState ( $Avi1, $GUI_AVISTART )
$Progress1 = GUICtrlCreateProgress(8, 128, 382, 15)
$Angabe_in_Prozent = GUICtrlCreateLabel("00%", 184, 168, 44, 28)
GUICtrlSetColor(-1, 0xFF0000)
$Datei_von_Server = GUICtrlCreateLabel("-------------------------------------------------------------------------------------------------------------------------------", 8, 112, 385, 17)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Text1 = GUICtrlCreateLabel("Downlaod Informationen", 144, 200, 119, 17)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Text2 = GUICtrlCreateLabel("Prozent Gedownloaded :", 16, 240, 121, 17)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Text3 = GUICtrlCreateLabel("Downloade Datei nach :", 16, 264, 119, 17)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Text4 = GUICtrlCreateLabel("MB Gedownloaded :", 16, 288, 101, 17)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Text5 = GUICtrlCreateLabel("Übertragungsrate :", 16, 312, 92, 17)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Text6 = GUICtrlCreateLabel("Geschätze Dauer :", 16, 336, 93, 17)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Text7 = GUICtrlCreateLabel("Downloade seit :", 16, 360, 83, 17)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Angabe_in_Prozent2 = GUICtrlCreateLabel("----------------------------------------------------------------------------------", 142, 239, 250, 17)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Pfad_Datei = GUICtrlCreateLabel("----------------------------------------------------------------------------------", 142, 263, 250, 17)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$MB_Gedownloaded = GUICtrlCreateLabel("------------------------------------------------------------------------------------", 142, 287, 248, 17)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Uebertragungsrate = GUICtrlCreateLabel("----------------------------------------------------------------------------------", 142, 311, 250, 17)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Geschaetzte_Dauer = GUICtrlCreateLabel("----------------------------------------------------------------------------------", 142, 335, 250, 17)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Download_Timer = GUICtrlCreateLabel("----------------------------------------------------------------------------------", 142, 359, 250, 17)
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Download_Abruch = GUICtrlCreateButton("Download Abrechen", 285, 392, 107, 25, 0)
GUICtrlSetOnEvent(-1, "Download_AbruchClick")
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xFF0000)
$Download_Starten = GUICtrlCreateButton("Download Starten", 168, 392, 99, 25, 0)
GUICtrlSetOnEvent(-1, "Download_StartenClick")
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x00FF00)
GUISetState(@SW_SHOW, $Download_GUI)
#EndRegion ### END Koda GUI section ###
Global $averagearr[1], $buffer = 0
$url = "http://dark.bellerophontes.eu/homepage/Map_Updates/Terra_Strife_Sides_Beta_2.rar";!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$Speicherpfad = "C:\Terra_Strife_Sides_Beta_2.rar"
Global $iFileSize = InetGetSize($url)
InetGet($url, $Speicherpfad,1,1);!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
GUICtrlSetData ( $Pfad_Datei, $Speicherpfad )
Global $Start = ("1")
AdlibEnable("Timer") ; Sekunden Zähler start
Global $timer = TimerInit() ; Der sekunden Zähler
Global $time = TimerInit() ; Die Geschätzte Downloadzeit
While @InetGetActive
;Beginn der Prozentrechnung und GUI Datensetzung
$Prozent = @InetGetBytesRead * 100 / $iFileSize
GUICtrlSetData ( $Progress1, $Prozent)
$Symbol_Prozent = "%"
$Prozent_Round = Round($Prozent,0)
$Prozent_und_Symbol = StringFormat("%s%s ", $Prozent_Round, $Symbol_Prozent)
GUICtrlSetData ( $Angabe_in_Prozent, $Prozent_und_Symbol )
GUICtrlSetData ( $Angabe_in_Prozent2, $Prozent_und_Symbol )
;Ende der Prozentrechnung und GUI Datensetzung
;Beginn der MB Rechnung
$Gesammte_MB_Ungerundet = ($iFileSize /1048576) ;Umrechnung von Bytes in MB
$Gesammte_MB = Round($Gesammte_MB_Ungerundet, 2);Rundung der MB
$Momentan_Gedownloadede_MB_Ungerundet = @InetGetBytesRead /1048576 ;Umrechnung von Bytes in MB
$Momentan_Gedownloadede_MB = Round($Momentan_Gedownloadede_MB_Ungerundet, 2);Rundung der MB
$MB_Fenster = StringFormat("%s MB von %s MB Gedownloaded ", $Momentan_Gedownloadede_MB, $Gesammte_MB) ;MB Anzeige
GUICtrlSetData ( $MB_Gedownloaded, $MB_Fenster)
;Ende der MB Rechnung
;Beginn der Download Speed ausrechnung
$Letzte_Kbits = ((@InetGetBytesRead)/1024)
Sleep (100)
$Neue_Kbits = ((@InetGetBytesRead)/1024)
$Kbits =($Neue_Kbits - $Letzte_Kbits)*10
$KiloBits_Symbol = ("KB\s")
$Downloadspeed = StringFormat("%s %s ", $Kbits, $KiloBits_Symbol)
GUICtrlSetData ( $Uebertragungsrate, $Downloadspeed)
;Ende der Download Speed ausrechnung
;Beginn der Stunden Minuten Sekunden Umrechnung
$ZEIT = _average($Kbits)
$Unspilt_Stunden = ($Zeit/3600)
$Stunden = StringSplit( $Unspilt_Stunden ,".")
$STD1 = $Stunden[1]
$Unspilt_Minuten = ($Zeit/60)
$Minuten = StringSplit( $Unspilt_Minuten ,".")
$MIN1 = ($Minuten[1]- ($Stunden[1]*60))
$Berechnung_Sekunden = ($Zeit - ($MIN1*60))
$SEK1= $Berechnung_Sekunden
$Downlod_Geschaetzte_Dauer = StringFormat("%s Std. %s Min. %s Sek.", $STD1, $MIN1, $SEK1)
GUICtrlSetData ( $Geschaetzte_Dauer, $Downlod_Geschaetzte_Dauer)
If $Prozent = 100 Then ExitLoop
WEnd
$Start = ("0")
;Reset der GUI
GUICtrlSetData ( $Progress1, "0")
GUICtrlSetData ( $Angabe_in_Prozent, "00%")
GUICtrlSetData ( $Datei_von_Server, "Fertig!")
GUICtrlSetData ( $Angabe_in_Prozent2, "00%")
GUICtrlSetData ( $Pfad_Datei, "Fertig!")
GUICtrlSetData ( $MB_Gedownloaded, "Fertig!")
GUICtrlSetData ( $Uebertragungsrate, "0 KB\s")
GUICtrlSetData ( $Geschaetzte_Dauer, "0 Std. 0 Min. 0 Sek.")
;GUICtrlSetData ( $Download_Timer, "")
While 1
Sleep(100)
WEnd
Func Download_GUIMinimize()
EndFunc
Func Download_GUIRestore()
EndFunc
Func Download_StartenClick()
EndFunc
Func Download_AbruchClick() ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
InetGet("abort") ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;Reset der GUI
$Start = ("0") ;Stop des Sekundenzählers
GUICtrlSetData ( $Progress1, "0")
GUICtrlSetData ( $Angabe_in_Prozent, "00%")
GUICtrlSetData ( $Datei_von_Server, "Abgebrochen!")
GUICtrlSetData ( $Angabe_in_Prozent2, "00%")
GUICtrlSetData ( $Pfad_Datei, "Abgebrochen!")
GUICtrlSetData ( $MB_Gedownloaded, "Abgebrochen!")
GUICtrlSetData ( $Uebertragungsrate, "0 KB\s")
GUICtrlSetData ( $Geschaetzte_Dauer, "0 Std. 0 Min. 0 Sek.")
;GUICtrlSetData ( $Download_Timer, "")
Sleep(1000)
MsgBox ( 16, "Abruch!", "Der Download wurde Abgebrochen" ,5 )
$1 = ("1")
GUISetState(@SW_HIDE, $Download_GUI)
Sleep(1000)
GUISetState(@SW_SHOW, $Download_GUI)
EndFunc
;----------------------average()------------------------------
Func _average($a)
If $a <> 0 Then
_ArrayAdd($averagearr, $a)
For $i = 1 To UBound($averagearr) - 1
$buffer += $averagearr[$i]
Next
$buffer /= UBound($averagearr) - 1
$buffer2 = $buffer
$buffer = 0
Return Round((($iFileSize - @InetGetBytesRead) / 1024) / $buffer2)
EndIf
EndFunc
;----------------------average()------------------------------
; --------------------------Timer()-----------------------------------
Func Timer()
$O = ("0")
If $Start > $O Then
_TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs )
Local $sTime = $Time ; save current time to be able to test and avoid flicker..
$Time = StringFormat("%01i Std. %01i Min. %01i Sek.", $Hour, $Mins, $Secs)
If $sTime <> $Time then ControlSetText("Download in Bearbeitung", "", $Download_Timer , $Time)
Else
EndIf
EndFunc ;==>Timer
; --------------------------Timer()-----------------------------------
Also die GUI startet und fängt an das teil runterzuladen ist supi.
Was ich jetz ereichen will ist das nachdem ich abrechen drücke der download abricht, geht auch.
Kurz warte und dan die GUI neu anfängt die datei runterzuladen.
Tut sie aber nicht sonder sie überspringt die schleife und geht sofort in den fertig modus.
Was mache ich falsch????