vbs to au3 für reconnect fritzbox

  • Wer kann mir das vbs script in au3 übersetzen?

    Code
    'fb_reconnect.vbs (c) 2009 by Michael Engelke <http://www.mengelke.de>
    On Error Resume Next
    host = InputBox("Bitte die Adresse der Fritz!Box eingeben!" & vbcrlf & vbcrlf & "Alternativ-Adressen:" & vbcrlf & "192.168.178.1 oder 169.254.1.1", _	"FB-Reconnect (c) 2009 by Michael Engelke","fritz.box")
    If host = False Then WScript.QuitEnd IfSet http = NothingSet http = CreateObject("WinHttp.WinHttpRequest.5.1")If http Is Nothing Then Set http = CreateObject("WinHttp.WinHttpRequest.5")If http Is Nothing Then Set http = CreateObject("WinHttp.WinHttpRequest")If http Is Nothing Then Set http = CreateObject("MSXML2.ServerXMLHTTP")If http Is Nothing Then Set http = CreateObject("Microsoft.XMLHTTP")If http Is Nothing Then MsgBox "Kein HTTP-Objekt verfügbar!",16,"Fehler:"Else'On Error Goto 0 body =	"<?xml version=""1.0"" encoding=""utf-8""?>" _  & "<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/"" s:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"">" _  & "<s:Body><u:ForceTermination xmlns:u=""urn:schemas-upnp-org:service:WANIPConnection:1"" /></s:Body>" _  & "</s:Envelope>" With http  .Open "POST", "http://" & host & ":49000/upnp/control/WANIPConn1",false  .setRequestHeader "Content-Type", "text/xml; charset=""utf-8"""  .setRequestHeader "Connection", "close"  .setRequestHeader "Content-Length", Len(body)  .setRequestHeader "HOST", host & ":49000"  .setRequestHeader "SOAPACTION", """urn:schemas-upnp-org:service:WANIPConnection:1#ForceTermination"""  .Send body End WithEnd If
  • Keine Ahnung ob der Inhalt so korrekt ist aber ich hätte es so übersetzt:

    Spoiler anzeigen
    [autoit]

    Global Const $AOBJLIST[5] = ["WinHttp.WinHttpRequest.5.1", "WinHttp.WinHttpRequest.5", "WinHttp.WinHttpRequest", "MSXML2.ServerXMLHTTP", "Microsoft.XMLHTTP"]
    Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
    Global $o_Http, $body
    Global Const $host = InputBox("FritzBox-Reconnect", "Bitte die Adresse der Fritz!Box eingeben!" & @CRLF & @CRLF & "Alternativ-Adressen:" & @CRLF & "192.168.178.1 oder 169.254.1.1" & @CRLF & @CRLF & "FB-Reconnect (c) 2009 by Michael Engelke", "fritz.box")

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

    ; HTTP-Objekt erzeugen
    For $i In $AOBJLIST
    $o_Http = ObjCreate($i)
    If Not @error Then ExitLoop
    Next
    If $o_Http = 0 Then Exit MsgBox(48, "Fehler", "Konnte kein Objekt erzeugen")

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

    $body = '<?xml version="1.0" encoding="utf-8"?>' _
    & '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' _
    & '<s:Body><u:ForceTermination xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1" /></s:Body>' _
    & "</s:Envelope>"

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

    With $o_Http
    .Open("POST", "http://" & $host & ":49000/upnp/control/WANIPConn1", False)
    .setRequestHeader("Content-Type", 'text/xml; charset="utf-8"')
    .setRequestHeader("Connection", "close")
    .setRequestHeader("Content-Length", StringLen($body))
    .setRequestHeader("HOST", $host & ":49000")
    .setRequestHeader("SOAPACTION", '"urn:schemas-upnp-org:service:WANIPConnection:1#ForceTermination"')
    .send($body)
    EndWith

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

    Func MyErrFunc()
    MsgBox(0, "AutoItCOM Test", "Ein COM-Fehler ist aufgetreten !" & @CRLF & @CRLF & _
    "err.description is: " & @TAB & $oMyError.description & @CRLF & _
    "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
    "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _
    "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
    "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
    "err.source is: " & @TAB & $oMyError.source & @CRLF & _
    "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
    "err.helpcontext is: " & @TAB & $oMyError.helpcontext)
    EndFunc ;==>MyErrFunc

    [/autoit]

    Einmal editiert, zuletzt von AspirinJunkie (7. November 2012 um 18:26)