Hängen in einer Schleife.....

  • Da ich für meinen Router kein IP-Resetscript gefunden habe, wollte ich dies über Autoit lösen.
    Grundsätzlich ja machbar, da man sich nur einloggen muss und einen Button drücken muss.

    Problem an der Sache ist nur, dass der case $button3 unendlich ausgeführt wird. wieso weis ich leider nicht so ganz. case $button2 läuft so wie es soll (könnte allerdings sein, dass es einfach nur nicht auffällt oO)
    gibt es eine möglichkeit, die WHILE zu beenden OHNE das programm zu beenden? exitloop hat mir das Programm immer zu gemacht.

    Hier einmal das (vllt etwas unübersichtliche) script:

    [autoit]

    $Username= "root"
    $PW="xxxxxxx"

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

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("EasyBox 602 Manager", 591, 349, 464, 189)
    $Group1 = GUICtrlCreateGroup(" Informationen ", 8, 8, 369, 329, $BS_FLAT)
    $List1 = GUICtrlCreateList("", 16, 24, 353, 305, BitOR($WS_VSCROLL,$WS_BORDER))
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button3 = GUICtrlCreateButton("Fenster schließen", 392, 312, 187, 25, $WS_GROUP)
    $Group2 = GUICtrlCreateGroup("Befehle", 384, 8, 201, 177)
    $Button1 = GUICtrlCreateButton("Neue IP besorgen", 392, 24, 187, 73, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Aktuelle Verbindungsinfos", 392, 104, 187, 73, $WS_GROUP)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button2
    #include <IE.au3>
    $ie=_IECreate("http://192.168.2.1", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)
    _IEQuit($ie)
    ;eingeloggt
    _GUICtrlListBox_ResetContent($List1)
    GUICtrlSetData($List1, "Verbindungsinformationen:")
    GUICtrlSetData($List1, "--------------------------------------")

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

    $ie=_IECreate("http://192.168.2.1/status_main.stm", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)

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

    $body = _IEBodyReadTEXT($ie)
    $bodyArray = StringSplit($body, @LF)
    For $x=1 to $bodyArray[0]
    If StringInStr($bodyArray[$x],"adsl:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Verbindung: " & $bodyToken[2] & " " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"modus:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Modus: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"download:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Download: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"upload:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Upload: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"wan ip:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Wan IP: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"dhcp server:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Server: " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"Anzahl DHCP-Clients")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Clients connected: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    Next
    _IEQuit($ie)
    Case $Button3
    Exit
    Case $Button1
    GUICtrlSetData($List1, "")
    ; #######################################################
    ; Neu Verbinden
    ; #######################################################
    #include <IE.au3>
    ; Loginform
    $IE=_IECreate("http://192.168.2.1", 0, 1)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)
    _GUICtrlListBox_ResetContent($List1)
    GUICtrlSetData($List1, "Restarte Internetverbindung")
    GUICtrlSetData($List1, "Dies wird ca 20 Sekunden dauern.")
    GUICtrlSetData($List1, "Bitte warten...")
    Sleep(2000)
    ;Zum Button navigieren
    ;Hier Anpassen!!!!
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{SPACE}")
    _IEQuit($IE)
    Sleep(20000)
    ; Neu Verbunden
    $ie=_IECreate("http://192.168.2.1", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)
    _IEQuit($ie)
    ;eingeloggt
    GUICtrlSetData($List1, "Verbindungsinformationen:")
    GUICtrlSetData($List1, "--------------------------------------")

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

    $ie=_IECreate("http://192.168.2.1/status_main.stm", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)

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

    $body = _IEBodyReadTEXT($ie)
    $bodyArray = StringSplit($body, @LF)
    For $x=1 to $bodyArray[0]
    If StringInStr($bodyArray[$x],"adsl:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Verbindung: " & $bodyToken[2] & " " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"modus:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Modus: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"download:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Download: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"upload:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Upload: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"wan ip:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Wan IP: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"dhcp server:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Server: " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"Anzahl DHCP-Clients")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Clients connected: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    Next
    _IEQuit($ie)
    EndSwitch
    WEnd

    [/autoit]

    Anderweitig wär interessant, wie man dieses "unendliche tab schreiben" abkürzen kann xD eventuell über eine funktion pressTab(5) damit er 5mal tab drückt oder so.
    hab versucht das mit einer for schleife zu lösen - habs aber nich hinbekommen :)

  • Ich verstehe dein Problem mit Button3 nicht!

    [autoit]


    Func pressTAB($n)
    Local $i
    For $i = 1 To $n
    Send("{TAB}")
    Sleep(100)
    Next
    EndFunc

    [/autoit]

    Probiere mal, ob die Funktion pressTAB() so funktioniert, wie du es haben willst.

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • tschuldigung xD meinte button1 xD

    sobald ich den drücke, reconnected er so oft, bis ich den dialog schließe xD

  • Hallo LuZ1F3R,
    da ich keinen Roter habe, heir einmal da abgespeckte Skript:

    Spoiler anzeigen
    [autoit]

    #include <IE.au3>
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Username = "root"
    $PW = "xxxxxxx"

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

    #region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("EasyBox 602 Manager", 591, 349, 464, 189)
    $Group1 = GUICtrlCreateGroup(" Informationen ", 8, 8, 369, 329, $BS_FLAT)
    $List1 = GUICtrlCreateList("", 16, 24, 353, 305, BitOR($WS_VSCROLL, $WS_BORDER))
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button3 = GUICtrlCreateButton("Fenster schließen", 392, 312, 187, 25, $WS_GROUP)
    $Group2 = GUICtrlCreateGroup("Befehle", 384, 8, 201, 177)
    $Button1 = GUICtrlCreateButton("Neue IP besorgen", 392, 24, 187, 73, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Aktuelle Verbindungsinfos", 392, 104, 187, 73, $WS_GROUP)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    ; Case $GUI_EVENT_CLOSE, $Button3 so geht es auch dann sparst du dir den case $Button3
    Exit
    Case $Button2
    MsgBox(0,"","Button 2")
    #cs
    $ie=_IECreate("http://192.168.2.1", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)
    _IEQuit($ie)
    ;eingeloggt
    _GUICtrlListBox_ResetContent($List1)
    GUICtrlSetData($List1, "Verbindungsinformationen:")
    GUICtrlSetData($List1, "--------------------------------------")

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

    $ie=_IECreate("http://192.168.2.1/status_main.stm", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)

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

    $body = _IEBodyReadTEXT($ie)
    $bodyArray = StringSplit($body, @LF)
    For $x=1 to $bodyArray[0]
    If StringInStr($bodyArray[$x],"adsl:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Verbindung: " & $bodyToken[2] & " " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"modus:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Modus: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"download:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Download: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"upload:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Upload: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"wan ip:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Wan IP: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"dhcp server:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Server: " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"Anzahl DHCP-Clients")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Clients connected: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    Next
    _IEQuit($ie)
    #ce
    Case $Button3
    MsgBox(0,"","Button 3")
    Exit
    Case $Button1
    MsgBox(0,"","Button 1")
    #cs
    GUICtrlSetData($List1, "")
    ; #######################################################
    ; Neu Verbinden
    ; #######################################################
    ; Loginform
    $IE=_IECreate("http://192.168.2.1", 0, 1)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)
    _GUICtrlListBox_ResetContent($List1)
    GUICtrlSetData($List1, "Restarte Internetverbindung")
    GUICtrlSetData($List1, "Dies wird ca 20 Sekunden dauern.")
    GUICtrlSetData($List1, "Bitte warten...")
    Sleep(2000)
    ;Zum Button navigieren
    ;Hier Anpassen!!!!
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{TAB}")
    Send("{SPACE}")
    _IEQuit($IE)
    Sleep(20000)
    ; Neu Verbunden
    $ie=_IECreate("http://192.168.2.1", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)
    _IEQuit($ie)
    ;eingeloggt
    GUICtrlSetData($List1, "Verbindungsinformationen:")
    GUICtrlSetData($List1, "--------------------------------------")

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

    $ie=_IECreate("http://192.168.2.1/status_main.stm", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)

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

    $body = _IEBodyReadTEXT($ie)
    $bodyArray = StringSplit($body, @LF)
    For $x=1 to $bodyArray[0]
    If StringInStr($bodyArray[$x],"adsl:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Verbindung: " & $bodyToken[2] & " " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"modus:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Modus: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"download:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Download: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"upload:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Upload: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"wan ip:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Wan IP: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"dhcp server:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Server: " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"Anzahl DHCP-Clients")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Clients connected: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    Next
    _IEQuit($ie)
    #ce
    EndSwitch
    WEnd

    [/autoit]

    in dem ich keinen Fehler finden kann. Falls du keinen ganz grassen Fehler (den ich dann leider übersehen habe) eingebaut hast sollte das Skript funktionieren, ansonsten schau dir [ offen ] Tutorial: Wie man Script-Fehler erfolgreich sucht/findet bzw. richtig debuggt an,

    mfg (Auto)Bert

  • naja die sache ist die,... ich drück auf den knopf fürs neu verbinden und er macht das unendlich oft - lässt sich auch kein anderer knopf mehr drücken (Wie schließen z.b.)

  • Ich sehe keinen grund wieso die Schleife spinnen sollte aber ich habe mal die Button1 funktion aus der schleife genommen und einfach mal in ne
    Func gepackt , versuchs jetzt mal , wer weiß....

    Spoiler anzeigen
    [autoit]

    $Username= "root"
    $PW="xxxxxxx"

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

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <IE.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("EasyBox 602 Manager", 591, 349, 464, 189)
    $Group1 = GUICtrlCreateGroup(" Informationen ", 8, 8, 369, 329, $BS_FLAT)
    $List1 = GUICtrlCreateList("", 16, 24, 353, 305, BitOR($WS_VSCROLL,$WS_BORDER))
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button3 = GUICtrlCreateButton("Fenster schließen", 392, 312, 187, 25, $WS_GROUP)
    $Group2 = GUICtrlCreateGroup("Befehle", 384, 8, 201, 177)
    $Button1 = GUICtrlCreateButton("Neue IP besorgen", 392, 24, 187, 73, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Aktuelle Verbindungsinfos", 392, 104, 187, 73, $WS_GROUP)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button2
    $ie=_IECreate("http://192.168.2.1", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)
    _IEQuit($ie)
    ;eingeloggt
    _GUICtrlListBox_ResetContent($List1)
    GUICtrlSetData($List1, "Verbindungsinformationen:")
    GUICtrlSetData($List1, "--------------------------------------")

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

    $ie=_IECreate("http://192.168.2.1/status_main.stm", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)

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

    $body = _IEBodyReadTEXT($ie)
    $bodyArray = StringSplit($body, @LF)
    For $x=1 to $bodyArray[0]
    If StringInStr($bodyArray[$x],"adsl:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Verbindung: " & $bodyToken[2] & " " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"modus:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Modus: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"download:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Download: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"upload:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Upload: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"wan ip:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Wan IP: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"dhcp server:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Server: " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"Anzahl DHCP-Clients")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Clients connected: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    Next
    _IEQuit($ie)
    Case $Button3
    Exit
    Case $Button1
    _newIP()

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

    EndSwitch
    WEnd

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

    Func _newIP()
    GUICtrlSetData($List1, "")
    ; #######################################################
    ; Neu Verbinden
    ; #######################################################
    ; Loginform
    $IE=_IECreate("http://192.168.2.1", 0, 1)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)
    _GUICtrlListBox_ResetContent($List1)
    GUICtrlSetData($List1, "Restarte Internetverbindung")
    GUICtrlSetData($List1, "Dies wird ca 20 Sekunden dauern.")
    GUICtrlSetData($List1, "Bitte warten...")
    Sleep(2000)
    ;Zum Button navigieren
    ;Hier Anpassen!!!!
    Send("{TAB 28}")
    Send("{SPACE}")
    _IEQuit($IE)
    Sleep(20000)
    ; Neu Verbunden
    $ie=_IECreate("http://192.168.2.1", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)
    _IEQuit($ie)
    ;eingeloggt
    GUICtrlSetData($List1, "Verbindungsinformationen:")
    GUICtrlSetData($List1, "--------------------------------------")

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

    $ie=_IECreate("http://192.168.2.1/status_main.stm", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)

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

    $body = _IEBodyReadTEXT($ie)
    $bodyArray = StringSplit($body, @LF)
    For $x=1 to $bodyArray[0]
    If StringInStr($bodyArray[$x],"adsl:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Verbindung: " & $bodyToken[2] & " " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"modus:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Modus: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"download:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Download: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"upload:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Upload: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"wan ip:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Wan IP: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"dhcp server:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Server: " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"Anzahl DHCP-Clients")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Clients connected: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    Next
    _IEQuit($ie)
    EndFunc

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

    Ich würde dir aber raten GUISetOnEvent zu verwenden ;)

    MfG Hellboy

    MfG hellboy

    [autoit]

    Do
    _help($user)
    Until $questions = 0

    [/autoit]

    Meine Werke:
    Ste`s Web-Radio

    Einmal editiert, zuletzt von hellboy3 (16. Juni 2010 um 12:36)

  • Nimm mal die #include Zeile bei Button1 und Button2 raus und füge diese einmal oben (bei den anderen Includes) ein.

    Zudem würde ich generell - wenn Du schon die GUIGetMsg() Funktion verwenden möchtest - in den Cases nur Subfunktionen aufrufen.
    Das macht das ganze viel übersichtlicher!

    Oder verwende gleich die GUISetOnEvent Funktion!

  • hmm werd ich die tage ma versuchen.

    aber ist dieses GUISetOnEvent auch für normale buttons nutzbar? ich hatte in der referenz nur allgemeine dinge wie maximieren, minimieren, cancel und mausaktionen gesehen. is mein erstes autoit script, daher bitt ich um nachsicht :D

  • Hallo

    naja die sache ist die,... ich drück auf den knopf fürs neu verbinden und er macht das unendlich oft - lässt sich auch kein anderer knopf mehr drücken (Wie schließen z.b.)


    meine abgespeckte Version auch nicht :?:
    Wenn nein, dann kommentiere nr noch die send Befehle aus, ich vermute, das eines dieser Send's an dein eigenes Skript geschickt wird. Wenn das funktoniert, ändere dein Skript in diesem Bereich mit Hilfe von _IE-Funktionen,

    mfg (Auto)Bert

  • Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <IE.au3>

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

    Global $Username= "root"
    Global $PW="xxxxxxx"
    Global $List1

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

    Opt('GUIOnEventMode', 1)

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

    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("EasyBox 602 Manager", 591, 349, 464, 189)
    GUISetOnEvent(-3, '_Exit')
    $Group1 = GUICtrlCreateGroup(" Informationen ", 8, 8, 369, 329, $BS_FLAT)
    $List1 = GUICtrlCreateList("", 16, 24, 353, 305, BitOR($WS_VSCROLL,$WS_BORDER))
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button3 = GUICtrlCreateButton("Fenster schließen", 392, 312, 187, 25, $WS_GROUP)
    GUICtrlSetOnEvent(-1, '_Exit')
    $Group2 = GUICtrlCreateGroup("Befehle", 384, 8, 201, 177)
    $Button1 = GUICtrlCreateButton("Neue IP besorgen", 392, 24, 187, 73, $WS_GROUP)
    GUICtrlSetOnEvent(-1, '_newIP')
    $Button2 = GUICtrlCreateButton("Aktuelle Verbindungsinfos", 392, 104, 187, 73, $WS_GROUP)
    GUICtrlSetOnEvent(-1, '_verbindungsinfos')
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While Sleep(100)
    WEnd

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

    Func _newIP()
    GUICtrlSetData($List1, "")
    ; #######################################################
    ; Neu Verbinden
    ; #######################################################
    ; Loginform
    $IE=_IECreate("http://192.168.2.1", 0, 1)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)
    _GUICtrlListBox_ResetContent($List1)
    GUICtrlSetData($List1, "Restarte Internetverbindung")
    GUICtrlSetData($List1, "Dies wird ca 20 Sekunden dauern.")
    GUICtrlSetData($List1, "Bitte warten...")
    Sleep(2000)
    ;Zum Button navigieren
    ;Hier Anpassen!!!!
    Send("{TAB 28}")
    Send("{SPACE}")
    _IEQuit($IE)
    Sleep(20000)
    ; Neu Verbunden
    $ie=_IECreate("http://192.168.2.1", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)
    _IEQuit($ie)
    ;eingeloggt
    GUICtrlSetData($List1, "Verbindungsinformationen:")
    GUICtrlSetData($List1, "--------------------------------------")

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

    $ie=_IECreate("http://192.168.2.1/status_main.stm", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)

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

    $body = _IEBodyReadTEXT($ie)
    $bodyArray = StringSplit($body, @LF)
    For $x=1 to $bodyArray[0]
    If StringInStr($bodyArray[$x],"adsl:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Verbindung: " & $bodyToken[2] & " " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"modus:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Modus: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"download:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Download: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"upload:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Upload: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"wan ip:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Wan IP: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"dhcp server:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Server: " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"Anzahl DHCP-Clients")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Clients connected: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    Next
    _IEQuit($ie)
    EndFunc

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

    Func _verbindungsinfos()
    $ie=_IECreate("http://192.168.2.1", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)
    _IEQuit($ie)
    ;eingeloggt
    _GUICtrlListBox_ResetContent($List1)
    GUICtrlSetData($List1, "Verbindungsinformationen:")
    GUICtrlSetData($List1, "--------------------------------------")

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

    $ie=_IECreate("http://192.168.2.1/status_main.stm", 0, 0)
    $form = _IEGetObjById($ie,'tF')
    $object = _IEGetObjByName($ie,'user')
    _IEFormElementSetValue($object, $Username)
    $object2 = _IEGetObjByName($ie,'pws')
    _IEFormElementSetValue($object2, $PW)
    _IEFormSubmit($form)

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

    $body = _IEBodyReadTEXT($ie)
    $bodyArray = StringSplit($body, @LF)
    For $x=1 to $bodyArray[0]
    If StringInStr($bodyArray[$x],"adsl:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Verbindung: " & $bodyToken[2] & " " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"modus:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Modus: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"download:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Download: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"upload:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Upload: " & $bodyToken[2] & " " & $bodyToken[3] & "kbps")
    EndIf
    If StringInStr($bodyArray[$x],"wan ip:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "Wan IP: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    If StringInStr($bodyArray[$x],"dhcp server:")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Server: " & $bodyToken[3])
    EndIf
    If StringInStr($bodyArray[$x],"Anzahl DHCP-Clients")<>0 then
    $bodyFound = $bodyArray[$x]
    $bodyToken = StringSplit($bodyFound, " ")
    GUICtrlSetData($List1, "DHCP Clients connected: " & $bodyToken[3] & " " & $bodyToken[4])
    EndIf
    Next
    _IEQuit($ie)
    EndFunc

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

    Func _Exit()
    Exit
    EndFunc

    [/autoit]

    Versuch das mal wenn das nicht funzt dann liegt`s wahrscheinlich am Send , siehe AutoBert :D

    MfG hellboy

    [autoit]

    Do
    _help($user)
    Until $questions = 0

    [/autoit]

    Meine Werke:
    Ste`s Web-Radio

    Einmal editiert, zuletzt von hellboy3 (16. Juni 2010 um 16:54)

  • hmm werd ich die tage ma versuchen.

    aber ist dieses GUISetOnEvent auch für normale buttons nutzbar? ich hatte in der referenz nur allgemeine dinge wie maximieren, minimieren, cancel und mausaktionen gesehen. is mein erstes autoit script, daher bitt ich um nachsicht :D


    Ja, sicher geht das!
    Du brauchst einfach

    [autoit]

    Opt("GUIOnEventMode", 1) ;Enable events on GUI

    [/autoit]

    und

    [autoit]

    GUICtrlSetOnEvent($bButtonXYZ, "_FuncXYZ")

    [/autoit]

    Sobald dieser entsprechende Button gedrückt ist, springt AutoIt automatisch in die Subfunktion. Einfacher gehts' dann nicht mehr!