Захотел сделать скрипт, который будет закрыть плеер vlc по команде которую он примет из TCP. Сервер, который будет отправлять команды готов, но клиент не работает. Прошу указать что сделал не так.
Вот сервер:
Клиент:
Вот сервер:
Код:
HotKeySet("{F1}", "_disconnect")
HotKeySet("{F2}", "_exit")
#include <Misc.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ###
$Form1_1 = GUICreate("RemoteControl", 284, 132, 192, 124)
$Button1 = GUICtrlCreateButton("Закрыть vlc", 0, 32, 81, 49)
$Disconnected = GUICtrlCreateLabel("Disconnected", 8, 8, 102, 25, $SS_CENTER)
$Button3 = GUICtrlCreateButton("Активировать подключение", 120, 0, 161, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button3
$disconnect = 0
TCPStartup()
$Socket = TCPListen("192.168.1.109", 5900, 100)
Do
$Connection = TCPAccept($Socket)
Until $Connection <> -1
If $disconnect = 0 Then
GUICtrlSetData($Disconnected, "Connected")
GUICtrlSetColor($Disconnected, 0x00FF00)
EndIf
If @error Then
MsgBox(16, "Error", "Связь прервана")
_exit()
EndIf
Case $Button1
$close = "vlc.exe"
TCPSend($Connection, $close)
EndSwitch
WEnd
Func _exit()
TCPCloseSocket($Connection)
TCPShutdown()
Exit
EndFunc
Func _disconnect()
$disconnect = 1
GUICtrlSetData($Disconnected, "Disconnect")
GUICtrlSetColor($Disconnected, 0xFF0000)
EndFunc
Клиент:
Код:
While 1
TCPStartup()
$Connection = TCPConnect("192.168.1.109", 5900)
$Resv = TCPRecv($Connection, 200)
If $Resv <> 0 Then
ProcessClose($Resv)
EndIf
Wend