Guten Tag zusammen,
ich habe gestern eine Update Funktion gebastelt , nur leider geht die _UpdateCheck2() Funktion nicht.
Immer wenn ich das Script starte und ich an diesem Punkt des Scripts ankomme , werden die Informationen
nicht an die Progressbar und Labels weitergegeben. Wenn man allerdings nur diese Funktion ( _UpdateCheck2 )
Alleine ausführt geht es.
Hier mein Script: ( Alle FTP Daten wurden zur Sicherheit entfernt )
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include-once
#include <FileConstants.au3>
#NoTrayIcon
#RequireAdmin
_Check()
Func _Check()
#Region ### START Koda GUI section ### Form=
AdlibRegister("_ProgressCheck", 500)
AdlibRegister("_timeCheck", 500)
Global $download = InetGet("PRIVAT", @UserProfileDir&"/UpdateInfo.ini", 1, 1)
Global $CheckGUI = GUICreate("Prüfe auf softwareaktualisierung...", 403, 93, 877, 470)
Global $CheckProgressLB = GUICtrlCreateLabel("Prüfe auf softwareaktualisierung...0%", 0, 8, 401, 25, $SS_CENTER)
GUICtrlSetFont(-1, 11, 800, 0, "Arial")
Global $CheckProgress = GUICtrlCreateProgress(8, 40, 386, 21)
Global $CheckKB = GUICtrlCreateLabel("0 / 0 KB", 296, 64, 104, 20, $SS_CENTER)
$Label2 = GUICtrlCreateLabel("Informationen werden ausgetauscht....", 8, 64, 226, 20, $SS_CENTER)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $timer = 0
Global $timer_start = False
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
EndFunc
Func _timeCheck()
[/autoit] [autoit][/autoit] [autoit]If InetGetInfo($download, 2) = False Then
If InetGetInfo($download, 0) > 0 And $timer_start = False Then
$timer = TimerInit()
$timer_start = True
EndIf
$time_calc = int((int(InetGetInfo($download, 1) / 1024) - (InetGetInfo($download, 0) / 1024)) _
/ int((InetGetInfo($download, 0) / 1024) / (TimerDiff($timer) / 1000)))
$Geschwindigkeit_calc = int(InetGetInfo($download, 0) / (TimerDiff($timer) / 1000))
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]If $time_calc <= 60 Then
[/autoit] [autoit][/autoit] [autoit]If $time_calc = 1 Then
$time = " 1 Sekunde"
Else
$time = $time_calc & " Sekunden"
EndIf
EndIf
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]If $time_calc > 60 Then
[/autoit] [autoit][/autoit] [autoit]If int($time_calc / 60) = 1 Then
$time = " 1 Minute"
Else
$time = int($time_calc / 60) & " Minuten"
EndIf
EndIf
[/autoit] [autoit][/autoit] [autoit]If $time_calc / 60 > 60 Then
[/autoit] [autoit][/autoit] [autoit]If int(($time_calc / 60) / 60) = 1 Then
$time = " 1 Tag"
Else
$time = int(($time_calc / 60) / 60) & " Tage"
EndIf
EndIf
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]If int($Geschwindigkeit_calc) <= 1024 Then
[/autoit] [autoit][/autoit] [autoit]$Geschwindigkeit = int($Geschwindigkeit_calc) & " B\s"
[/autoit] [autoit][/autoit] [autoit]EndIf
[/autoit] [autoit][/autoit] [autoit]If int($Geschwindigkeit_calc) > 1024 Then
[/autoit] [autoit][/autoit] [autoit]$Geschwindigkeit = int($Geschwindigkeit_calc / 1024) & " KB\s"
[/autoit] [autoit][/autoit] [autoit]EndIf
[/autoit] [autoit][/autoit] [autoit]If int($Geschwindigkeit_calc / 1024) > 1024 Then
[/autoit] [autoit][/autoit] [autoit]$Geschwindigkeit = int(($Geschwindigkeit_calc / 1024) / 1024) & " KB\s"
[/autoit] [autoit][/autoit] [autoit]EndIf
[/autoit] [autoit][/autoit] [autoit]If int(($Geschwindigkeit_calc / 1024) / 1024) > 1024 Then
[/autoit] [autoit][/autoit] [autoit]$Geschwindigkeit = int((($Geschwindigkeit_calc / 1024) / 1024) / 1024) & " KB\s"
[/autoit] [autoit][/autoit] [autoit]EndIf
Else
Sleep(50)
_UpdateCheck2()
EndIf
EndFunc ;==>_time
[/autoit] [autoit][/autoit] [autoit]Func _ProgressCheck()
GUICtrlSetData($CheckProgress, int((InetGetInfo($download, 0) / InetGetInfo($download, 1)) * 100)) ;aktualiesierung des Progresses
GUICtrlSetData($CheckKB, int(InetGetInfo($download, 0) / 1024) & " / " & int( _
InetGetInfo($download, 1) / 1024) & " kb")
GUICtrlSetData($CheckProgressLB, "Prüfe auf softwareaktualisierung..." & int((InetGetInfo($download, 0) / InetGetInfo($download, 1)) * 100) & "%") ;aktualiesierung des $$kb_and_procent_labels
EndFunc ;==>_Progress
Func _UpdateCheck2()
$size = WinGetPos($CheckGUI, $CheckGUI)
#Region ### START Koda GUI section ### Form=
$UpdateGefunden = GUICreate("(1) Update wurde gefunden und ist bereit zur Installation !", 610, 308, $size[0], $size[1])
$GetInformation = GUICtrlCreateButton("Weitere Informationen zum Update", 304, 192, 227, 25)
GUICtrlSetCursor (-1, 0)
$Group1 = GUICtrlCreateGroup("", 88, 48, 441, 137)
$Label1 = GUICtrlCreateLabel("Sehr geehrter Benutzer,", 96, 64, 143, 20)
$Label2 = GUICtrlCreateLabel("eine neue Software version "&IniRead(@UserProfileDir&"/UpdateInfo.ini","Allgemein","Ver","0.0.1")&" von "&IniRead(@UserProfileDir&"/UpdateInfo.ini","Allgemein","betreiber","Unbekannt")&" ist verfügbar.", 96, 80, 430, 20)
$Label3 = GUICtrlCreateLabel("Wir bitten sie diese so schnell wie möglich herrunterzuladen um unsere", 96, 96, 420, 20)
$Label4 = GUICtrlCreateLabel("Software weiter nutzen zu können.", 96, 112, 201, 20)
$Label5 = GUICtrlCreateLabel("Um weitere Informationen zum Update", 296, 112, 229, 20)
$Label6 = GUICtrlCreateLabel("zu erhalten können sie uns online unter:", 96, 128, 234, 20)
$Label7 = GUICtrlCreateLabel(IniRead(@UserProfileDir&"/UpdateInfo.ini","Allgemein","homepage","Wartungsmodus"), 328, 128, 195, 20, $SS_CENTER)
GUICtrlSetFont(-1, 8, 400, 4, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000080)
GUICtrlSetCursor (-1, 0)
$Label8 = GUICtrlCreateLabel("Besuchen. Vielen Dank das sie sich für unser Programm entschieden", 96, 144, 412, 20)
$Label9 = GUICtrlCreateLabel("haben.", 96, 160, 45, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$DownloadNew = GUICtrlCreateButton("Update jetzt Herrunterladen", 304, 224, 227, 25, $BS_DEFPUSHBUTTON)
GUICtrlSetCursor (-1, 0)
$runOldVer = GUICtrlCreateButton("Alte Version Starten", 304, 256, 227, 25)
GUICtrlSetCursor (-1, 0)
$Label10 = GUICtrlCreateLabel("(1) Update wurde gefunden und ist bereit zur Installation !", 56, 8, 503, 25)
GUICtrlSetFont(-1, 11, 800, 0, "Arial")
$Label12 = GUICtrlCreateLabel(IniRead(@UserProfileDir&"/UpdateInfo.ini","Allgemein","Support","Wartungsmodus"), 0, 224, 302, 23, $SS_CENTER)
GUICtrlSetFont(-1, 10, 400, 4, "Times New Roman")
GUICtrlSetColor(-1, 0x000080)
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)
GUIDelete($CheckGUI)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $runOldVer
GUIDelete($UpdateGefunden)
_Old()
Case $DownloadNew
GUIDelete($UpdateGefunden)
_UpdateNOW()
Case $GetInformation
ShellExecute(IniRead(@UserProfileDir&"/UpdateInfo.ini","Allgemein","homepage","Wartungsmodus"))
Case $Label12
ShellExecute(IniRead(@UserProfileDir&"/UpdateInfo.ini","Allgemein","Support","Wartungsmodus"))
Case $Label7
ShellExecute(IniRead(@UserProfileDir&"/UpdateInfo.ini","Allgemein","homepage","Wartungsmodus"))
EndSwitch
WEnd
EndFunc
Func _UpdateNOW()
AdlibRegister("_Progress", 500)
AdlibRegister("_time", 500)
Global $download2 = InetGet("PRIVAT", @UserProfileDir&"/Update.exe", 1, 1)
Global $Form4 = GUICreate("(1) Update wird herruntergeladen und installiert...", 756, 207, 717, 366)
Global $Label10 = GUICtrlCreateLabel("(1) Update wird herruntergeladen und installiert...0%", 0, 8, 755, 25, $SS_CENTER)
GUICtrlSetFont(-1, 11, 800, 0, "Arial")
$Label1 = GUICtrlCreateLabel("Eine neue Software Version von wird herruntergeladen und installiert.", 184, 128, 408, 20)
$Label2 = GUICtrlCreateLabel("Dieser Vorgang kann einige Minuten in Anspruch nehmen und setzt", 184, 144, 398, 20)
$Label3 = GUICtrlCreateLabel("eine bestehende Internetverbindung vorraus.", 184, 160, 269, 20)
Global $Progress = GUICtrlCreateProgress(8, 64, 742, 29)
$Label4 = GUICtrlCreateLabel(@ScriptFullPath, 8, 40, 744, 20)
Global $KB = GUICtrlCreateLabel("0 / 0 KB", 8, 96, 240, 20)
Global $Label6 = GUICtrlCreateLabel("0 Minute(n) verbleiben", 240, 96, 311, 20, $SS_CENTER)
Global $Label7 = GUICtrlCreateLabel("0 KB\s", 616, 96, 130, 20, $SS_CENTER)
$Group1 = GUICtrlCreateGroup("", 168, 112, 433, 73)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Button1 = GUICtrlCreateButton("Programm Starten", 616, 160, 123, 25)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetCursor(-1,0)
Global $Button2 = GUICtrlCreateButton("Bug Report", 616, 128, 123, 25)
GUICtrlSetCursor(-1,0)
GUICtrlSetState(-1, $GUI_DISABLE)
Global $Label8 = GUICtrlCreateLabel("www.sa-roleplay.net", 0, 144, 167, 19, $SS_CENTER)
GUICtrlSetFont(-1, 8, 800, 4, "Times New Roman")
GUICtrlSetCursor(-1,0)
GUICtrlSetColor(-1, 0x000080)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $timer = 0
Global $timer_start = False
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
ShellExecute(IniRead(@UserProfileDir&"/UpdateInfo.ini","Allgemein","homepage","Wartungsmodus"))
Case $Label8
ShellExecute(IniRead(@UserProfileDir&"/UpdateInfo.ini","Allgemein","homepage","Wartungsmodus"))
Case $Button1
_SelfUpdate(@ScriptFullPath, True, 30, False)
EndSwitch
WEnd
EndFunc
Func _time()
[/autoit] [autoit][/autoit] [autoit]If InetGetInfo($download2, 2) = False Then
If InetGetInfo($download2, 0) > 0 And $timer_start = False Then
$timer = TimerInit()
$timer_start = True
EndIf
$time_calc = int((int(InetGetInfo($download2, 1) / 1024) - (InetGetInfo($download2, 0) / 1024)) _
/ int((InetGetInfo($download2, 0) / 1024) / (TimerDiff($timer) / 1000)))
$Geschwindigkeit_calc = int(InetGetInfo($download2, 0) / (TimerDiff($timer) / 1000))
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]If $time_calc <= 60 Then
[/autoit] [autoit][/autoit] [autoit]If $time_calc = 1 Then
$time = " 1 Sekunde"
Else
$time = $time_calc & " Sekunden"
EndIf
EndIf
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]If $time_calc > 60 Then
[/autoit] [autoit][/autoit] [autoit]If int($time_calc / 60) = 1 Then
$time = " 1 Minute"
Else
$time = int($time_calc / 60) & " Minuten"
EndIf
EndIf
[/autoit] [autoit][/autoit] [autoit]If $time_calc / 60 > 60 Then
[/autoit] [autoit][/autoit] [autoit]If int(($time_calc / 60) / 60) = 1 Then
$time = " 1 Tag"
Else
$time = int(($time_calc / 60) / 60) & " Tage"
EndIf
EndIf
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]If int($Geschwindigkeit_calc) <= 1024 Then
[/autoit] [autoit][/autoit] [autoit]$Geschwindigkeit = int($Geschwindigkeit_calc) & " B\s"
[/autoit] [autoit][/autoit] [autoit]EndIf
[/autoit] [autoit][/autoit] [autoit]If int($Geschwindigkeit_calc) > 1024 Then
[/autoit] [autoit][/autoit] [autoit]$Geschwindigkeit = int($Geschwindigkeit_calc / 1024) & " KB\s"
[/autoit] [autoit][/autoit] [autoit]EndIf
[/autoit] [autoit][/autoit] [autoit]If int($Geschwindigkeit_calc / 1024) > 1024 Then
[/autoit] [autoit][/autoit] [autoit]$Geschwindigkeit = int(($Geschwindigkeit_calc / 1024) / 1024) & " KB\s"
[/autoit] [autoit][/autoit] [autoit]EndIf
[/autoit] [autoit][/autoit] [autoit]If int(($Geschwindigkeit_calc / 1024) / 1024) > 1024 Then
[/autoit] [autoit][/autoit] [autoit]$Geschwindigkeit = int((($Geschwindigkeit_calc / 1024) / 1024) / 1024) & " KB\s"
[/autoit] [autoit][/autoit] [autoit]EndIf
GUICtrlSetData($Label6, $time)
GUICtrlSetData($Label7, $Geschwindigkeit)
Else
Sleep(50)
GUICtrlSetState($Button1, $GUI_ENABLE)
GUICtrlSetState($Button2, $GUI_ENABLE)
AdlibUnRegister("_Progress")
AdlibUnRegister("_time")
EndIf
EndFunc ;==>_time
[/autoit] [autoit][/autoit] [autoit]Func _Progress()
GUICtrlSetData($Progress, int((InetGetInfo($download2, 0) / InetGetInfo($download2, 1)) * 100)) ;aktualiesierung des Progresses
GUICtrlSetData($KB, int(InetGetInfo($download2, 0) / 1024) & " / " & int( _
InetGetInfo($download2, 1) / 1024) & " kb")
GUICtrlSetData($Label10, "(1) Update wird herruntergeladen und installiert..." & int((InetGetInfo($download2, 0) / InetGetInfo($download2, 1)) * 100) & "%") ;aktualiesierung des $$kb_and_procent_labels
EndFunc ;==>_Progress
Func _SelfUpdate($sUpdatePath, $fRestart = Default, $iDelay = 5, $fUsePID = Default, $fBackupPath = Default)
Local $iInternalDelay = 2, $sAppID = @ScriptName, $sDelay = 'IF %TIMER% GTR ' & $iDelay & ' GOTO DELETE', _
$sBackupPath = '', $sImageName = 'IMAGENAME', $sRestart = '', $sScriptPath = @ScriptFullPath, $sTempFileName = @ScriptName
If @Compiled = 0 Or FileExists($sUpdatePath) = 0 Then
Return SetError(1, 0, 0)
EndIf
$sTempFileName = StringLeft($sTempFileName, StringInStr($sTempFileName, '.', 1, -1) - 1)
[/autoit] [autoit][/autoit] [autoit]If $fBackupPath Or $fBackupPath = Default Then
$sBackupPath = 'MOVE /Y ' & '"' & $sScriptPath & '"' & ' "' & @ScriptDir & '\' & $sTempFileName & '_Backup.exe' & '"' & @CRLF
EndIf
While FileExists(@TempDir & '\' & $sTempFileName & '.bat')
$sTempFileName &= Chr(Random(65, 122, 1))
WEnd
$sTempFileName = @TempDir & '\' & $sTempFileName & '.bat'
If $iDelay = Default Then
$iDelay = 5
EndIf
If $iDelay = 0 Then
$sDelay = ''
EndIf
If $fUsePID Then
$sAppID = @AutoItPID
$sImageName = 'PID'
EndIf
If $fRestart Then
$sRestart = 'START "" "' & $sScriptPath & '"'
EndIf
Local $sData = 'SET TIMER=0' & @CRLF _
& ':START' & @CRLF _
& 'PING -n ' & $iInternalDelay & ' 127.0.0.1 > nul' & @CRLF _
& $sDelay & @CRLF _
& 'SET /A TIMER+=1' & @CRLF _
& @CRLF _
& 'TASKLIST /NH /FI "' & $sImageName & ' EQ ' & $sAppID & '" | FIND /I "' & $sAppID & '" >nul && GOTO START' & @CRLF _
& 'GOTO MOVE' & @CRLF _
& @CRLF _
& ':MOVE' & @CRLF _
& 'TASKKILL /F /FI "' & $sImageName & ' EQ ' & $sAppID & '"' & @CRLF _
& $sBackupPath & _
'GOTO END' & @CRLF _
& @CRLF _
& ':END' & @CRLF _
& 'MOVE /Y ' & '"' & $sUpdatePath & '"' & ' "' & $sScriptPath & '"' & @CRLF _
& $sRestart & @CRLF _
& 'DEL "' & $sTempFileName & '"'
Local $hFileOpen = FileOpen($sTempFileName, $FO_OVERWRITE)
If $hFileOpen = -1 Then
Return SetError(2, 0, 0)
EndIf
FileWrite($hFileOpen, $sData)
FileClose($hFileOpen)
Return Run($sTempFileName, @TempDir, @SW_HIDE)
EndFunc
Func _Old()
MsgBox(0,":)","Mein Normales Script... Bla Bla Bla....")
Exit
EndFunc