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"
#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 ###
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, "--------------------------------------")
$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)
$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, "--------------------------------------")
$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)
$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
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