AutoIt Hilfe Updater

  • Hallo hab mich ein bischen mit den Regulären Ausdrücken beschäftigt, und rausgekommen ist dieser AutoIt Hilfe Updater.
    Es wird nur die 7za.exe benötigt (http://downloads.sourceforge.net/sevenzip/7za465.zip)

    Vielleicht habt ihr ja Verbesserungsvorschläge.

    Spoiler anzeigen
    [autoit]


    #cs ----------------------------------------------------------------------------
    AutoIt Version: 3.3.4.0
    Author: XTC99

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

    Script Function: Update Autoit Help in German
    #ce ----------------------------------------------------------------------------
    #RequireAdmin
    #include <INet.au3>
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form
    $Form1 = GUICreate("AutoIt Hilfe Updater", 478, 188, -1, -1)
    $TopLabel = GUICtrlCreateLabel("AutoIt Hilfe Updater", 144, 8, 184, 28)
    $FileName_Label = GUICtrlCreateLabel("", 16, 48, 450, 17)
    $Status_Label = GUICtrlCreateLabel("", 16, 104, 450, 17)
    $Progress_bar = GUICtrlCreateProgress(16, 72, 450, 17)
    $Update_Button = GUICtrlCreateButton("Update", 56, 144, 75, 25, $WS_GROUP)
    $Exit_Button = GUICtrlCreateButton("Exit", 336, 144, 75, 25, $WS_GROUP)
    GUICtrlSetFont($TopLabel, 15, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    dim $install_autoit_path = ''
    _SearchParthOfAutoit()

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Update_Button
    _Analyse_PHP_Files()
    Exit
    Case $Exit_Button
    Exit
    EndSwitch
    WEnd

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

    Func _SearchParthOfAutoit()
    $AutoitRegKey = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoIt3Script\Shell\Compile\Command", "")
    if ($AutoitRegKey <> "") Then
    local $autoit_path_array = StringRegExp($AutoitRegKey, "((?i:[a-z]){1}:+\\.*)\\(?i:aut2exe\\)",3)
    dim $install_autoit_path = $autoit_path_array[0]
    EndIf
    EndFunc

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

    Func _Analyse_PHP_Files()
    local $autoit_downloads_php_url = 'http://translation.autoit.de/autoitinfo/autoit_downloads.php'
    local $autoit_hilfe_php_url = 'http://translation.autoit.de/hilfe.php'

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

    local $autoit_downloads_php = (_INetGetSource($autoit_downloads_php_url))
    local $autoit_hilfe_php = (_INetGetSource($autoit_hilfe_php_url))

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

    local $last_help_version = StringRegExp($autoit_downloads_php, "-([0-9,\_]+).zip",3)
    local $autoit_german_help = StringRegExp($autoit_hilfe_php, "='(h.*" & $last_help_version[0] & ".zip*)'>",3)

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

    For $i=0 to (UBound($autoit_german_help)-1)
    local $FileNameArray = StringSplit($autoit_german_help[$i], "/")
    local $FileURL = $autoit_german_help[$i]
    local $FileName = $FileNameArray[(UBound($FileNameArray)-1)]
    _CheckforNecessaryUpdate ($FileURL,$FileName)
    Next
    EndFunc

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

    Func _CheckforNecessaryUpdate ($FileURL,$FileName)
    local $FileSizeURL = InetGetSize ($FileURL)
    if FileExists (@ScriptDir & "\" & $FileName) Then
    local $FileSizeHD = FileGetSize(@ScriptDir & "\" & $FileName)
    if ($FileSizeHD = $FileSizeURL) Then
    MsgBox(64,"Autoit Updater",$FileName & " ist aktuell")
    Else
    _DownloadFile ($FileURL,$FileName)
    EndIf
    Else
    _DownloadFile ($FileURL,$FileName)
    EndIf
    EndFunc

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

    Func _DownloadFile ($FileURL,$FileName)
    GUICtrlSetData($FileName_Label, $FileName )
    local $FileSizeURL = InetGetSize ($FileURL)
    local $Download_Handle = InetGet($FileURL,@ScriptDir & '\' & $FileName,1,1)
    local $InetGetInfo_Data = InetGetInfo($Download_Handle)
    local $InetGetBytesRead = $InetGetInfo_Data[0]
    local $Percentage = 0
    While $InetGetBytesRead < $FileSizeURL
    local $InetGetInfo_Data = InetGetInfo($Download_Handle)
    local $InetGetBytesRead = $InetGetInfo_Data[0]
    local $Percentage = $InetGetBytesRead/$FileSizeURL*100
    GUICtrlSetData($Progress_bar, $Percentage)
    GUICtrlSetData($Status_Label, Round($InetGetBytesRead / 1024 ) & " of " & Round($FileSizeURL / 1024) & " KB")
    Sleep(500)
    WEnd
    local $Download_Complete = $InetGetInfo_Data[2]
    If ($Download_Complete = 'true') Then
    ProgressOff()
    InetClose($Download_Handle)
    _UnzipHelpToAutoitDir ($FileName)
    EndIf
    EndFunc

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

    Func _UnzipHelpToAutoitDir ($FileName)
    $helptyp = StringRegExp($FileName, '\A([A-Z,a-z,0-9].*?)-',3)
    $extractpath = ''
    if $helptyp[0] = "AutoIt" Then
    local $extractpath = $install_autoit_path
    ElseIf $helptyp[0] = "au3" Then
    local $extractpath = $install_autoit_path & '\SciTE\api'
    ElseIf $helptyp[0] = "Beispiele" Then
    local $extractpath = $install_autoit_path & '\Examples'
    EndIf
    if ($extractpath <> '') Then
    EnvSet("path", (EnvGet("path") &";" & @ScriptDir & "\;"))
    RunWait(@ComSpec & ' /c 7za.exe x "'& @ScriptDir & '\' & $FileName &'" -y -o"' & $extractpath & '"',@ScriptDir,@SW_HIDE)
    EndIf
    EndFunc

    [/autoit]

    ----------------------------------------------------------------------------------------------------------------------
    Früher musste man Drachen töten und konnte die Jungfrau heiraten.
    Heute gibt es keine Jungfrauen mehr, man muss den Drachen heiraten!

  • Ich an deiner Stelle würde das entpacken mit der Zip-UDF lösen.

    Mfg Cartan12

    Dateien

    Spoiler anzeigen

    Grundkenntnisse in: C++, JavaScript
    Sehr gute Kenntnisse: PHP, JAVA, C und näturlich AutoIt


    Klaviatur, Anhang UDF, GDI+ Mühle

    Zitat

    "Wenn einen um 20h der Pizzadienst anruft und fragt, ob man's nur vergessen hat und ob man das gleiche
    möchte wie immer -- dann sollte man sein Bestellverhalten evtl überdenken"