Hallo Liebes Forum.
Hier ein super Script zum updaten der Version.
Falls die Version des scripts älter ist kann die neue runtergeladen werden.
Diese wird direkt entpackt ![]()
Alle datein die man braucht sind im Anhang.
Bitte auf Feedback.
Spoiler anzeigen
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <INet.au3>
Const $vUpdateServer = "deinedomain.de" ; Deine domain um checken ohne www und http
Const $vScriptFile = "http://www.deinedomain.de/version.txt" ; Zum checken der neuen version
Const $vChangelogFile = "http://www.deinedomain.de/changelog.txt" ; Was sich geändert hat
Const $vUnrarDLL = "http://www.deinedomain.de/unrar.dll" ; Benötigt man einfach
Const $vMapFiles = "http://www.deinedomain.de/changelog.rar" ; Dort packst du einfach alle Datein rein die entpackt werden soll
HotKeySet("{END}", "_exit")
$INI = @ScriptDir & "\Data.ini"
$vVersion = "1.12" ; Die version die das Script hat. Wird mit die aus dem Internet überpruft.
$vGUIColor = 0x161616
$vGUIColor2 = 0x161616
Dim $hGUIListChangelog
If Not FileExists(@ScriptDir & "\Data\") Then ; Ordner erstellen
DirCreate(@ScriptDir & "\Data\")
EndIf
If Not FileExists($INI) Then
IniWrite($INI, "Default", "Titel", "(C) The-Franky 2010 - 2011 Visit: http://www.forum.the-franky.de Thanks")
EndIf
#region UpdateGUI
;UpdateGUI
$vGUIStandartHeight = 290
$vGUILargeHeight = $vGUIStandartHeight + 327
$vGUIStandartWidth = 778
$vGUIColor = 0x161616
$hGUI = GUICreate("Tralala v" & $vVersion, $vGUIStandartWidth - 6, $vGUIStandartHeight) ; Das Gui wo am ende der Changelog drin steht wenn es eine neue version gibt.
$hGUIUpdate = GUICreate("Tralala - Update", 500, 305, -1, -1, -1, 0x00000080, $hGUI)
GUISetBkColor($vGUIColor, $hGUIUpdate)
$hGUILabelNewVersion = GUICtrlCreateLabel("", 10, 10, 480, 17)
GUICtrlSetColor(-1, 0xFFFFFF)
$hGUIListChangelog = GUICtrlCreateList("", 10, 30, 480, 240, BitOR(0x4000, 0x0100, 0x00200000))
GUICtrlSetBkColor(-1, $vGUIColor)
GUICtrlSetColor(-1, 0xFFFFFF)
$hGUIButtonDownload = GUICtrlCreateButton("Download", 10, 275, 235, 20)
$hGUIButtonCancelUpdate = GUICtrlCreateButton("Cancel", 255, 275, 235, 20)
GUISetState(@SW_HIDE)
#endregion UpdateGUI
MainGui() ; Das normale GUI wird erstellt ![]()
Func MainGui()
Opt("GUIOnEventMode", 0)
$maingui = GUICreate("Main Gui", 260, 175, -1, -1)
$hGUILabelUpdateAndSApfelInfo = GUICtrlCreateLabel("", 25, 14, 84, 17)
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetState(-1, 32)
GUICtrlCreateLabel("Test2", 53, 38, 55, 17)
$check = GUICtrlCreateButton("Check", 10, 88, 240, 20)
$groupgeneral2 = GUICtrlCreateGroup("Info", 10, 113, 240, 42)
$Label1 = GUICtrlCreateLabel("Made by" & "Franky", 24, 128, 205, 19)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW, $maingui)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]While 1
Switch GUIGetMsg($maingui)
Case -3
Exit
Case $check
_FU_ClickUpdateCheck()
Case $hGUIButtonDownload
_FU_ClickButtonDownload()
Case $hGUIButtonCancelUpdate, $hGUIUpdate
_FU_ClickButtonCancelUpdate()
EndSwitch
Sleep(10)
WEnd
GUIDelete($maingui)
Sleep(100)
EndFunc ;==>MainGui
[/autoit] [autoit][/autoit] [autoit]Func _exit()
Sleep(10)
Exit
EndFunc ;==>_exit
; Hier wird gecheckt ob man verbindung zum word-wide-web hat
;Aber auch ob es ein Fehler gab
;Und ob die neuste version schon benutzt wird.
Func _FU_ClickUpdateCheck()
_FU_UpdateCheck($vVersion)
If @error = 1 Then
MsgBox(48, "Connection timeout", "You either do not have a connection to the world wide web or the server is currently down.")
ElseIf @error = 2 Then
MsgBox(48, "Error", "Error getting the version!")
ElseIf @error = 3 Then
MsgBox(64, "No update available", "You are using the latest version (v" & $vVersion & ").")
Else
GUISetState(@SW_SHOW, $hGUIUpdate) ;5
EndIf
EndFunc ;==>_FU_ClickUpdateCheck
Func _FU_UpdateCheck($vCurrentVersion)
If Ping($vUpdateServer) = 0 Then
SetError(1)
Else
$vLatestVersion = _INetGetSource_($vScriptFile)
If @error Then
SetError(2)
Else
If $vCurrentVersion <> $vLatestVersion Then
GUICtrlSetData($hGUILabelNewVersion, "There is a new version available (old: " & $vCurrentVersion & " | new: " & $vLatestVersion & ").")
$vChangelog = StringSplit(_INetGetSource_($vChangelogFile), @CRLF)
For $i = 1 To $vChangelog[0]
GUICtrlSendMsg($hGUIListChangelog, 0x0180, 0, $vChangelog[$i])
Next
Return SetError(0, 0, $vLatestVersion)
Else
SetError(3)
EndIf
EndIf
EndIf
Return 0
EndFunc ;==>_FU_UpdateCheck
Func _INetGetSource_($s_URL, $bString = True)
Local $sString = InetRead($s_URL, 1)
Local $nError = @error, $nExtended = @extended
If $bString Then $sString = BinaryToString($sString)
Return SetError($nError, $nExtended, $sString)
EndFunc ;==>_INetGetSource_
Func _FU_ClickButtonDownload()
GUISetState(@SW_HIDE, $hGUIUpdate)
GUICtrlSetData($hGUIListChangelog, "")
_FU_MapFilesInstall()
EndFunc ;==>_FU_ClickButtonDownload
Func _FU_ClickButtonCancelUpdate()
GUISetState(@SW_HIDE, $hGUIUpdate)
GUICtrlSetData($hGUIListChangelog, "")
EndFunc ;==>_FU_ClickButtonCancelUpdate
Func _FU_MapFilesInstall()
$v_MapFiles = @TempDir & "\dateiname.rar" ; wird nur gespeichert ,damit es entpackt werden kann
ProgressOn("Downloading...", "Loading 'unrar.dll'", "")
[/autoit] [autoit][/autoit] [autoit]$v_SizeUnrarDLL = Round(InetGetSize($vUnrarDLL) / 1024)
$hDownload = InetGet($vUnrarDLL, @TempDir & "\unrar.dll", 1, 1)
Do
$v_DLBytes = Round(InetGetInfo($hDownload, 0) / 1024)
$v_DLPercent = Round($v_DLBytes / $v_SizeUnrarDLL * 100)
ProgressSet($v_DLPercent, @LF & $v_DLBytes & "/" & $v_SizeUnrarDLL & "KB " & $v_DLPercent & "%")
Sleep(100)
Until InetGetInfo($hDownload, 2)
ProgressSet(0, "", "Loading 'DateiName.rar'")
[/autoit] [autoit][/autoit] [autoit]$v_SizeMapFilesRar = Round(InetGetSize($vMapFiles) / 1024)
Local $hDownload = InetGet($vMapFiles, $v_MapFiles, 1, 1)
Do
$v_DLBytes = Round(InetGetInfo($hDownload, 0) / 1024)
$v_DLPercent = Round($v_DLBytes / $v_SizeMapFilesRar * 100)
ProgressSet($v_DLPercent, @LF & $v_DLBytes & "/" & $v_SizeMapFilesRar & "KB " & $v_DLPercent & "%")
Sleep(200)
Until InetGetInfo($hDownload, 2)
ProgressSet(100, @LF & "This may take some seconds.", "Installing DateiName...")
$bExtractionSuc = _FU_RARExtract(@TempDir & "\unrar.dll", $v_MapFiles)
Sleep(2000)
[/autoit] [autoit][/autoit] [autoit]FileDelete(@TempDir & "\unrar.dll")
FileDelete($v_MapFiles)
If $bExtractionSuc = 1 Then
ProgressSet(100, @LF & "Installation done. Have fun!", "Installing DateiName...")
Sleep(3000)
Else
For $i = 15 To 1 Step - 1
ProgressSet(100, "Error occured. Please make sure that you are connected" & @CRLF & "to the www and that SBot Manager was started in" & @CRLF & "32 bit mode. Continuing in " & $i & " seconds", "Installing DateiName...")
Sleep(1000)
Next
EndIf
ProgressOff()
EndFunc ;==>_FU_MapFilesInstall
;Auto extraction of rar archives into the scriptdirectory
Func _FU_RARExtract($v_UnrarDLL, $v_RarFile) ;$v_UnrarDLL = path to unrar.dll file, $v_RarFile = path to rar file
Local $sResult
$rar_ArchivName = DllStructCreate("char[260]")
DllStructSetData($rar_ArchivName, 1, $v_RarFile)
$rar_CmtBuf = DllStructCreate("char[16384]")
For $iCount = 1 To 16384
$sResult &= " "
Next
DllStructSetData($rar_CmtBuf, 1, $sResult)
$rar_Str = DllStructCreate("ptr;uint;uint;ptr;uint;uint;uint")
[/autoit] [autoit][/autoit] [autoit]DllStructSetData($rar_Str, 1, DllStructGetPtr($rar_ArchivName))
DllStructSetData($rar_Str, 2, 1) ;1 = $RAR_OM_EXTRACT
DllStructSetData($rar_Str, 3, 0)
DllStructSetData($rar_Str, 4, DllStructGetPtr($rar_CmtBuf))
DllStructSetData($rar_Str, 5, 16384)
DllStructSetData($rar_Str, 6, 0)
DllStructSetData($rar_Str, 7, 0)
$rar_Header_CmtBuf = DllStructCreate("char[16384]")
$rar_Header_Str = DllStructCreate("char[260];char[260];uint;uint;uint;uint;uint;uint;uint;uint;uint;ptr;uint;uint;uint")
DllStructSetData($rar_Header_Str, 12, DllStructGetPtr($rar_Header_CmtBuf))
If FileExists($v_UnrarDLL) Then
$DLLUnrar = DllOpen($v_UnrarDLL)
$rar_OpenedArchive = DllCall($DLLUnrar, "int", "RAROpenArchive", "ptr", DllStructGetPtr($rar_Str))
If IsArray($rar_OpenedArchive) Then
$iCount = 0
Do
$rar_Header = DllCall($DLLUnrar, "int", "RARReadHeader", "ptr", $rar_OpenedArchive[0], "ptr", DllStructGetPtr($rar_Header_Str))
DllCall($DLLUnrar, "int", "RARProcessFile", "ptr", $rar_OpenedArchive[0], "int_ptr", 2, "ptr", "", "ptr", "") ;2 = $RAR_EXTRACT
$iCount += 1
Until $rar_Header[0] <> 0 Or $iCount = 20
DllCall($DLLUnrar, "int", "RARCloseArchive", "int", $rar_OpenedArchive[0])
DllClose($DLLUnrar)
Return 1
EndIf
EndIf
Return 0
EndFunc ;==>_FU_RARExtract