本帖最后由 xms77 于 2012-6-2 13:02 编辑
回复 1# yingf20 #include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("语音", 460, 444)
$ListView1 = GUICtrlCreateListView("计算机|号数信息|播放时间|IP地址", 0, 0, 458, 414)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100);调整宽度
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100);调整宽度
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100);调整宽度
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 100);调整宽度
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES);设置表格边框
GUICtrlSetCursor(-1, 0);鼠标指针
GUISetState(@SW_SHOW)
TCPStartup(); 开始 TCP 服务
$ip = IniRead(@ScriptDir & '\wglm.ini', 'Config', 'ServerIP', '192.168.0.7');从配置文件中读取IP
$port = IniRead(@ScriptDir & '\wglm.ini', 'Config', 'ServerPort', '21991');从配置文件中读取端口
$tcpMainListen = TCPListen($ip, $port, 100);创建监听,用于接收数据
If $tcpMainListen = -1 Then
MsgBox(4096, '错误', '创建监听失败!')
Exit
EndIf
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
$tcpSocket = TCPAccept($tcpMainListen);接收客户端连接
If $tcpSocket <> -1 Then;客户端连接成功
While 1
$TcpRecvData = TCPRecv($tcpSocket, 2048, 1);接收客户端发送的数据
If @error Then ExitLoop ;如果接收信息出现错误,则退出循环.
If $TcpRecvData <> '' Then
;===你需要的代码如下=========================================================================
$splited = StringSplit(BinaryToString($TcpRecvData),"|") ;接受到的信息以“|”符号来分割到数组
;下面是语音播报
$sTalk = "狗日的"& $splited[2] & "呼叫操蛋的服务器,听到请回答."
$oVoice = ObjCreate("SAPI.SpVoice")
$oVoice.Volume = 100
$oVoice.Speak($sTalk)
;====代码结束================================================================================
$TcpRecvData = GUICtrlCreateListViewItem(BinaryToString($TcpRecvData, 4), $ListView1);将信息写入到$listview1控件
ExitLoop
EndIf
WEnd
EndIf
WEnd
|