We call from the terminal
I decided to publish a short note on how you can use the basic programming knowledge to realize the ability to make calls from a terminal server.
Who needs it: first of all, it will be interesting to those people (or organizations) who have a terminal server (for example, windows 2003), it has some CRM program in which contact information on clients is stored. And employees use software IP phones.
What we have: a local network, a terminal server itself [we have Windows 2003 Standart], an IP telephony server [Asterisk], client machines [Windows XP] with an installed software IP phone [X-lite].
General idea:on the terminal server [hereinafter TS] there must be a certain program [client part. Next, KCh], which determines which IP address Vasily Pupkin came from [I ask all VPs not to be offended :)]. A certain server program hangs on Vasily’s computer and listens on the port [hereinafter MF]. The question arises - why is there an MF on the server, and an MF on the client machine? The thing is that on the server the program will not listen to the ports, but will “connect” to the client machine and send the number on which it is necessary to call.
To solve this problem, I used AutoIt3 and a small program GETTSCIP , running which through the console we get our IP in the terminal [just what we need]
1. We write the midrange [will be on the client machine].As we said earlier, the program listens on the port [in this example, 65532]. If data arrives, it searches for a window with a specific title [X-lite. For other IP phones, you can use Autoit Window Info, which comes standard with AutoIt], activate the IP phone, send the received numbers, enter it into the IP phone, and press Enter. Example script: 2. We write KCH [will stand on a terminal server].
So, we specify the phone number as a parameter. This will allow us to insert, for example, a button for calling to 1C [for example, in our CRM]. Next, the CC determines the IP address from which the client entered the terminal. And over UDP sends him a phone number. Accordingly, the employee at this moment the midrange is triggered and a call occurs. Script example [pre-copy the GETTSCIP program with the name getmyip.exe into the system directory]: That's all. Now you can put a button on the vehicle in 1C or another program with the execution of the 2nd part of the program, the parameter of which is the phone number. Client, server for Xlite and getmyip can be downloaded in the archive here .
Who needs it: first of all, it will be interesting to those people (or organizations) who have a terminal server (for example, windows 2003), it has some CRM program in which contact information on clients is stored. And employees use software IP phones.
What we have: a local network, a terminal server itself [we have Windows 2003 Standart], an IP telephony server [Asterisk], client machines [Windows XP] with an installed software IP phone [X-lite].
General idea:on the terminal server [hereinafter TS] there must be a certain program [client part. Next, KCh], which determines which IP address Vasily Pupkin came from [I ask all VPs not to be offended :)]. A certain server program hangs on Vasily’s computer and listens on the port [hereinafter MF]. The question arises - why is there an MF on the server, and an MF on the client machine? The thing is that on the server the program will not listen to the ports, but will “connect” to the client machine and send the number on which it is necessary to call.
To solve this problem, I used AutoIt3 and a small program GETTSCIP , running which through the console we get our IP in the terminal [just what we need]
1. We write the midrange [will be on the client machine].As we said earlier, the program listens on the port [in this example, 65532]. If data arrives, it searches for a window with a specific title [X-lite. For other IP phones, you can use Autoit Window Info, which comes standard with AutoIt], activate the IP phone, send the received numbers, enter it into the IP phone, and press Enter. Example script: 2. We write KCH [will stand on a terminal server].
Local $szServerPC = @ComputerName
Local $szIPADDRESS = TCPNameToIP($szServerPC)
$socket = UDPBind($szIPADDRESS, 65532)
If @error <> 0 Then Exit
While 1
$data = UDPRecv($socket, 50)
If $data <> "" Then
WinActivate("XLite")
Send($data & "{enter}")
EndIf
sleep(100)
WEnd
Func OnAutoItExit()
UDPCloseSocket($socket)
UDPShutdown()
EndFunc
So, we specify the phone number as a parameter. This will allow us to insert, for example, a button for calling to 1C [for example, in our CRM]. Next, the CC determines the IP address from which the client entered the terminal. And over UDP sends him a phone number. Accordingly, the employee at this moment the midrange is triggered and a call occurs. Script example [pre-copy the GETTSCIP program with the name getmyip.exe into the system directory]: That's all. Now you can put a button on the vehicle in 1C or another program with the execution of the 2nd part of the program, the parameter of which is the phone number. Client, server for Xlite and getmyip can be downloaded in the archive here .
if($CmdLine[0]==1) then
Local $foo = Run(@ComSpec & " /c getmyip", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line
Local $ip
While 1
$line = StdoutRead($foo)
If @error Then ExitLoop
if $line<>'' then
$ip=$line
EndIf
Wend
$ip=StringReplace($ip,"WTSClientAddress: ","");
$socket = UDPOpen($ip, 65532)
If @error <> 0 Then Exit
$status = UDPSend($socket, $CmdLine[1])
If $status = 0 then
MsgBox(0, "ERROR", "Error while sending UDP message: " & @error)
Exit
EndIf
EndIf
Func OnAutoItExit()
UDPCloseSocket($socket)
UDPShutdown()
EndFunc