Version 1.1 x64
Funktionen:
1.) WLAN_EIN
2.) WLAN_AUS
3.) NEUE_IP
4.) NEU_STARTEN
5.) SEND_TEXT
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.12.0
Author: m47
Version: 1.1
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]; Script Start - Add your code below here
[/autoit] [autoit][/autoit] [autoit]#include <Misc.au3>
#include <GUIConstants.au3>
Opt("MustDeclareVars", 1) ;1 = Variable muss deklariert werden
Opt("GUIOnEventMode",1) ;Aktiviert die OnEvent Funktionsanmeldung.
Opt("MouseCoordMode", 0) ;relative Koordinaten zum aktiven Fenster
Global $Script_Name = "THOMSON TG585 v7 - Tool" ;THOMSON TG585 v7 (CANT-P) = WLAN-Router mit internem DSL-Modem
;http://wiki.openwrt.org/toh/thomson/tg585
If _Singleton($Script_Name,1) = 0 Then
Sound() ;
Exit
EndIf
;Loop
Global $i
;GUI
Global $GUIGetMsg
;Button
Global $Button_Sperre = 0 ;0=AUS, 1=Ein
;Doubleclick_Button
Global $Timer_DblClick
Global $Counter_DblClick = 0
Global $Switch_MousePos = True
Global $MouseGetPos
Global $Mouse_DoubleClickSpeed = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "DoubleClickSpeed")
;TCP
Global $TCPRecv
;Timer
Global $Timer_Modem_Restart
Global $Timer_Modem_Wait_Off
Global $Timer_Modem_Wait_On
;Data
Dim $Data[31]
$Data[0] = "192.168.1.254" ;Modem_IP
$Data[1] = "23" ;Standart Port(http://de.wikipedia.org/wiki/Liste_der…disierten_Ports)
$Data[2] = ""
$Data[3] = "" ;Username
$Data[4] = "" ;Password
$Data[5] = ""
$Data[6] = "wireless ifconfig state=enabled" ;WLAN_EIN
$Data[7] = "wireless ifconfig state=disabled" ;WLAN_AUS
$Data[8] = ""
$Data[9] = "ppp ifdetach intf = Internet" ;NEUE_IP(Teil 1)
$Data[10] = "ppp ifattach intf = Internet" ;NEUE_IP(Teil 2)
$Data[11] = ""
$Data[12] = "system reboot" ;NEU_STARTEN
$Data[13] = ""
$Data[14] = "2048" ;Maximale Anzahl der zu erhaltenen Daten/Zeichen von einem verbundenen "Socket" mit TCPRecv Befehl
$Data[15] = ""
$Data[16] = ">" ;Wird ins Fenster geschrieben(Zeilenanfang)
$Data[17] = ""
$Data[18] = "500" ;Pausezeit für Modem Rückmeldung. Falls Verbindung zum Modem langsam oder für Testzwecke den Wert erhöhen.
$Data[19] = "2000" ;Zusatzpausezeit für Modem Rückmeldung.
$Data[20] = "2000" ;Pausezeit nach TCPShutdown
$Data[21] = ""
$Data[22] = "Fehler"
$Data[23] = "Kann keine Verbindung herstellen."
$Data[24] = "Warten bis Modem abgestellt ist..."
$Data[25] = "Warten bis Modem eingeschalten ist..."
$Data[26] = " Sekunde(n) Gesamtzeit"
$Data[27] = ""
$Data[28] = "www.google.de" ;Ping Adresse für Verbindungstest
$Data[29] = ""
$Data[30] = "exit" ;Exit
;Command_Sequence
Dim $Command_Sequence_1[4] = [3,4,6,30] ;Befehlsfolge WLAN_EIN
Dim $Command_Sequence_2[4] = [3,4,7,30] ;Befehlsfolge WLAN_AUS
Dim $Command_Sequence_3[5] = [3,4,9,10,30] ;Befehlsfolge NEUE_IP
Dim $Command_Sequence_4[4] = [3,4,12,30] ;Befehlsfolge NEU_STARTEN
Dim $Command_Sequence_5[3] = [3,4,29] ;Befehlsfolge SEND_TEXT ,29=Platzhalter für Text
;Switch_Command_Sequence
Dim $Switch_Command_Sequence = 0
;Switch_Modem_Connected
Dim $Switch_Modem_Connected = -1 ;(-1) = mit Modem nicht verbunden, (<> -1) = mit Modem verbunden
;Counter_Connect_Receive_Send
Dim $Counter_Command_Sequence_ = 0
;OnAutoItExitRegister
OnAutoItExitRegister(OnAutoItExit) ;Funktion OnAutoItExit starten wenn AutoIt Script beendet(Exit oder per Hand geschlossen)wurde.
;GUICreate
Dim $GUICreate_Telnet_Client = GUICreate($Script_Name,800,800) ;Erstellt ein GUI-Fenster.
GUISetFont(12, 800, 0, "MS Sans Serif") ;Legt die Standardschriftart eines GUI-Fensters fest.
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_EVENT_CLOSE") ;die Dialogbox wird geschlossen (entweder durch einen bestimmten Button oder das Systemmenü).
GUISetOnEvent($GUI_EVENT_MINIMIZE, "GUI_EVENT_MINIMIZE") ;die Dialogbox wird per Button in der Titelleiste minimiert.
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "GUI_EVENT_MAXIMIZE") ;die Dialogbox wird per Button in der Titelleiste maximiert.
GUISetOnEvent($GUI_EVENT_RESTORE, "GUI_EVENT_RESTORE") ;die Dialogbox wird durch Klick auf das Taskleistensymbol wiederhergestellt.
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, '_PRdown') ;die erste (linke) Maustaste wurde gedrückt
GUISetOnEvent($GUI_EVENT_PRIMARYUP, '_PRup') ;die erste (linke) Maustaste wurde losgelassen
;
Dim $Input_GUICreate_Telnet_Client = GUICtrlCreateInput("",10,10,780,40) ;Erstellt eine Eingabe-Dialogbox für die GUI.
GUICtrlSetFont($Input_GUICreate_Telnet_Client,18) ;Setzt die Schriftart und Schriftgröße für ein Control.
GUICtrlSetBkColor($Input_GUICreate_Telnet_Client,0xffffff) ;White ;Setzt die Hintergrundfarbe eines Controls.
;
Dim $Button_WLAN_EIN = GUICtrlCreateButton("WLAN_EIN",10,60,150,40,$BS_DEFPUSHBUTTON) ;Erzeugt eine Schaltfläche mit einem dicken, schwarzen Rand (Default-Schaltfläche).
GUICtrlSetFont($Button_WLAN_EIN,16) ;Setzt die Schriftart und Schriftgröße für ein Control.
GUICtrlSetBkColor($Button_WLAN_EIN,0xC0DCC0) ;MoneyGreen ;Setzt die Hintergrundfarbe eines Controls.
;
Dim $Button_WLAN_AUS = GUICtrlCreateButton("WLAN_AUS",160,60,150,40,$BS_DEFPUSHBUTTON)
GUICtrlSetFont($Button_WLAN_AUS,16)
GUICtrlSetBkColor($Button_WLAN_AUS,0xC0DCC0) ;MoneyGreen
;
Dim $Button_NEUE_IP = GUICtrlCreateButton("NEUE_IP",310,60,150,40,$BS_DEFPUSHBUTTON)
GUICtrlSetFont($Button_NEUE_IP,16)
GUICtrlSetBkColor($Button_NEUE_IP,0xC0DCC0) ;MoneyGreen
;
Dim $Button_NEU_STARTEN = GUICtrlCreateButton("NEU_STARTEN",460,60,170,40,$BS_DEFPUSHBUTTON)
GUICtrlSetFont($Button_NEU_STARTEN,16)
GUICtrlSetBkColor($Button_NEU_STARTEN,0xC0DCC0) ;MoneyGreen
;
Dim $Button_SEND_TEXT = GUICtrlCreateButton("SEND_TEXT",630,60,160,40,$BS_DEFPUSHBUTTON)
GUICtrlSetFont($Button_SEND_TEXT,16)
GUICtrlSetBkColor($Button_SEND_TEXT,0xffffff) ;White
;
Dim $Edit_GUICreate_Telnet_Client = GUICtrlCreateEdit("",10,110,780,680,$WS_DISABLED) ;Erzeugt ein Fenster, das von Anfang an inaktiv ist.
GUICtrlSetFont($Edit_GUICreate_Telnet_Client,12) ;Setzt die Schriftart und Schriftgröße für ein Control.
GUICtrlSetBkColor($Edit_GUICreate_Telnet_Client,0x000000) ;Black ;Setzt die Hintergrundfarbe eines Controls.
GUISetState(@SW_SHOWNORMAL) ;Verändert den Status eines GUI-Fensters. @SW_SHOWNORMAL - Aktiviert und stellt ein Fenster dar
[/autoit] [autoit][/autoit] [autoit];GUI_Loop
While 1
Sleep(100)
WEnd
;Function
Func _PRdown()
If $Button_Sperre = 0 Then
$MouseGetPos = MouseGetPos() ;
[/autoit] [autoit][/autoit] [autoit]If _CheckCtrlDblClick($GUICreate_Telnet_Client, $Button_WLAN_EIN) Then
GUICtrlSetBkColor($Button_WLAN_EIN, 0xFF0000) ;Red
Sound() ;
WLAN_EIN() ;
GUICtrlSetBkColor($Button_WLAN_EIN, 0xC0DCC0) ;MoneyGreen
ElseIf _CheckCtrlDblClick($GUICreate_Telnet_Client, $Button_WLAN_AUS) Then
GUICtrlSetBkColor($Button_WLAN_AUS, 0xFF0000) ;Red
Sound() ;
WLAN_AUS() ;
GUICtrlSetBkColor($Button_WLAN_AUS, 0xC0DCC0) ;MoneyGreen
ElseIf _CheckCtrlDblClick($GUICreate_Telnet_Client, $Button_NEUE_IP) Then
GUICtrlSetBkColor($Button_NEUE_IP, 0xFF0000) ;Red
Sound() ;
NEUE_IP() ;
GUICtrlSetBkColor($Button_NEUE_IP, 0xC0DCC0) ;MoneyGreen
ElseIf _CheckCtrlDblClick($GUICreate_Telnet_Client, $Button_NEU_STARTEN) Then
GUICtrlSetBkColor($Button_NEU_STARTEN, 0xFF0000) ;Red
Sound() ;
NEU_STARTEN() ;
GUICtrlSetBkColor($Button_NEU_STARTEN, 0xC0DCC0) ;MoneyGreen
ElseIf _CheckCtrlDblClick($GUICreate_Telnet_Client, $Button_SEND_TEXT) Then
GUICtrlSetBkColor($Button_SEND_TEXT, 0xFF0000) ;Red
Sound() ;
SEND_TEXT() ;
GUICtrlSetBkColor($Button_SEND_TEXT, 0xffffff) ;White
Else
$Switch_MousePos = False
EndIf
EndIf
EndFunc
Func _PRup()
If $Switch_MousePos Then
If $Counter_DblClick = 2 Then
$Counter_DblClick = 0
Else
$Timer_DblClick = TimerInit() ;
EndIf
EndIf
EndFunc
Func _CheckCtrlDblClick($GUI, $CTRL)
Local $CtrlPos = ControlGetPos($GUI, '', $CTRL)
If ($MouseGetPos[0] >= $CtrlPos[0] And $MouseGetPos[0] <= $CtrlPos[0] + $CtrlPos[2]) And _
($MouseGetPos[1] >= $CtrlPos[1] + 20 And $MouseGetPos[1] <= $CtrlPos[1] + 20 + $CtrlPos[3]) Then
$Counter_DblClick += 1
$Switch_MousePos = True
If $Counter_DblClick = 2 And (TimerDiff($Timer_DblClick) < $Mouse_DoubleClickSpeed) Then
Return True
Else
$Timer_DblClick = TimerInit() ;
$Counter_DblClick = 1
EndIf
EndIf
EndFunc
Func WLAN_EIN()
$Switch_Command_Sequence = 1 ;WLAN_EIN
Connect_Receive_Send() ;
EndFunc
Func WLAN_AUS()
$Switch_Command_Sequence = 2 ;WLAN_AUS
Connect_Receive_Send() ;
EndFunc
Func NEUE_IP()
$Switch_Command_Sequence = 3 ;NEUE_IP
Connect_Receive_Send() ;
EndFunc
Func NEU_STARTEN()
$Switch_Command_Sequence = 4 ;NEU_STARTEN
Connect_Receive_Send() ;
EndFunc
Func SEND_TEXT()
$Switch_Command_Sequence = 5 ;SEND_TEXT
Connect_Receive_Send() ;
EndFunc
Func Connect_Receive_Send()
While 1
$Button_Sperre = 1 ;Buttons gesperrt
TCPStartup() ;Stellt den TCP Dienst zur Verfügung
[/autoit] [autoit][/autoit] [autoit]$Switch_Modem_Connected = TCPConnect($Data[0],$Data[1]) ;Verbinden
[/autoit] [autoit][/autoit] [autoit]If $Switch_Modem_Connected = -1 Then ;Verbindung zum Modem prüfen
MsgBox(16, $Data[22], $Data[23])
Sound() ;
ExitLoop
EndIf
For $i In Eval("Command_Sequence_" & $Switch_Command_Sequence) ;Daten($Data) in der Schleife abarbeiten
[/autoit] [autoit][/autoit] [autoit];Schleifendurchgangzähler
$Counter_Command_Sequence_ += 1
;Pause
Sleep($Data[18])
;Consolewrite
Consolewrite("Schritt " & $Counter_Command_Sequence_ & "/" & Ubound(Eval("Command_Sequence_" & $Switch_Command_Sequence)) &@LF)
If $Counter_Command_Sequence_ = Ubound(Eval("Command_Sequence_" & $Switch_Command_Sequence)) Then
Consolewrite(@LF)
EndIf
;~ Consolewrite($TCPRecv)
;Schleife verlassen wenn Schleifendurchgangzähler größer als Anzahl der Daten(Command_Sequence)
If $Counter_Command_Sequence_ > Ubound(Eval("Command_Sequence_" & $Switch_Command_Sequence)) Then
Consolewrite(@LF)
ExitLoop
EndIf
;Empfangen
$TCPRecv = TCPRecv($Switch_Modem_Connected, $Data[14]) ;Maximale Anzahl der zu erhaltenen Daten/Zeichen festlegen
If @error Then
ExitLoop
EndIf
If $TCPRecv <> "" Then
GUICtrlSetData($Edit_GUICreate_Telnet_Client, $Data[16] & $TCPRecv & @CRLF & GUICtrlRead($Edit_GUICreate_Telnet_Client)) ;die vom Modem empfangenen Daten ins Fenster schreiben
EndIf
;Senden($Input_GUICreate_Telnet_Client)
If $Switch_Command_Sequence = 5 And $Counter_Command_Sequence_ = 3 Then ;5=SEND_TEXT
TCPSend($Switch_Modem_Connected, GUICtrlRead(($Input_GUICreate_Telnet_Client), 1) & @CRLF) ;Inhalt vom Eingabefeld senden
GUICtrlSetData($Input_GUICreate_Telnet_Client,"") ;Eingabefeld leeren
GUICtrlSetState($Input_GUICreate_Telnet_Client,$GUI_FOCUS) ;$GUI_FOCUS = Das Control erhält den Eingabe- bzw. Auswahlfokus
Else
;Senden($Data)
TCPSend($Switch_Modem_Connected, $Data[$i] & @CRLF)
EndIf
;Zusatzpause
If $Switch_Command_Sequence = 3 And $Counter_Command_Sequence_ = 4 Then ;3=NEUE_IP
Sleep($Data[19])
EndIf
Next
Disconnect_Receive_Send() ;Verbindung trennen
[/autoit] [autoit][/autoit] [autoit]While 1
If $Switch_Command_Sequence = 4 Then ;4=NEU_STARTEN
$Timer_Modem_Restart = TimerInit() ;
$Timer_Modem_Wait_Off = TimerInit() ;
GUICtrlSetData($Edit_GUICreate_Telnet_Client, $Data[16] & $Data[24] & @CRLF & GUICtrlRead($Edit_GUICreate_Telnet_Client))
While Ping($Data[28])
Sleep(1000)
If TimerDiff($Timer_Modem_Wait_Off) > 30000 Then ExitLoop 2
WEnd
$Timer_Modem_Wait_On = TimerInit() ;
GUICtrlSetData($Edit_GUICreate_Telnet_Client, $Data[16] & $Data[25] & @CRLF & GUICtrlRead($Edit_GUICreate_Telnet_Client))
$i= GUICtrlRead($Edit_GUICreate_Telnet_Client)
While Not Ping($Data[28])
GUICtrlSetData($Edit_GUICreate_Telnet_Client, $Data[16] & Round(TimerDiff($Timer_Modem_Restart)/1000) & $Data[26] & @CRLF & $i)
Sleep(1000)
If TimerDiff($Timer_Modem_Wait_On) > 300000 Then ExitLoop 2
WEnd
ExitLoop
Else
ExitLoop
EndIf
WEnd
GUICtrlSetData($Edit_GUICreate_Telnet_Client, $Data[16] & @CRLF & GUICtrlRead($Edit_GUICreate_Telnet_Client)) ;Leerzeile ins Fenster schreiben
$Counter_Command_Sequence_ = 0 ;Schleifendurchgangzähler Reset
$Button_Sperre = 0 ;Buttons entperrt
Sleep($Data[20]) ;Pausezeit nach TCPShutdown
ExitLoop ;Zurück zur GUI
WEnd
EndFunc
Func Disconnect_Receive_Send()
If $Switch_Modem_Connected <> - 1 Then
TCPCloseSocket($Switch_Modem_Connected)
EndIf
TCPShutdown()
EndFunc
Func OnAutoItExit()
Disconnect_Receive_Send() ;
Sound() ;
EndFunc
Func GUI_EVENT_CLOSE()
Exit
EndFunc
Func GUI_EVENT_MINIMIZE()
Sound() ;
EndFunc
Func GUI_EVENT_MAXIMIZE()
Sound() ;
EndFunc
Func GUI_EVENT_RESTORE()
Sound() ;
EndFunc
Func Sound()
Beep(200,200)
EndFunc