Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Send Commands to Pc Navigator", 400, 200, -1, -1)
$Label1 = GUICtrlCreateLabel("Pc Navigator return : ***", 10, 34, 390, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Combo1 = GUICtrlCreateCombo("", 64, 64, 300, 25)
GUICtrlSetData(-1, "$destination=44.869740,-0.566483;navigate" & _
"|$window=100,500,1000,800,border" & _
"|$window=0,73,800,472,noborder" & _
"|$navigation_statistics" & _
"|$message="&chr(34)&"c'est un message"&chr(34)&";instant" & _
"|$message="&chr(34)&"ceci est un message"&chr(34)&";ask;instant" & _
"|$stop_navigation" & _
"|$last_position" & _
"|$sound_volume=0" & _
"|$sound_volume=100" & _
"|$minimize" & _
"|$restore" & _
"|exit" & _
"|$set_mode=day" & _
"|$set_mode=night" & _
"|$chat=message" & _
"|$software_version" & _
"|$protocol_version", "$destination=44.869740,-0.566483;navigate")
$Button1 = GUICtrlCreateButton("Exit",300,150,80,30)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Dim $command
$port = "4242"
$ip = "127.0.0.1"
Opt("TCPTimeout", 2000) ;100 milliseconds
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE,$Button1
Exit
Case $Combo1
$command = GUICtrlRead($Combo1)
TCPStartup()
$socket = TCPConnect($ip,$port)
If $socket = -1 Then
MsgBox(16,"Erreur","Erreur de connexion : " & @error)
Exit
EndIf
$msgAEnvoyer = $command & @lf
If Not $msgAEnvoyer = "" Then TCPSend($socket,$msgAEnvoyer)
$recv = TCPRecv($socket,255)
;If Not $recv = "" Then MsgBox(64,"Message reçu","Le programme vous a renvoyé : " & $recv)
If Not $recv = "" Then GuiCtrlSetData($Label1, "Pc Navigator return : "&$recv)
TCPCloseSocket ( $socket )
EndSwitch
WEnd