下面源码改成S/C(有服务端和客户端模式)
参考这里的代码修改成http://www.autoitx.com/forum.php?mod=viewthread&tid=2499&highlight=%D4%F5%D1%F9%B5%F7%D3%C3%D3%EF%D2%F4%B0%FC%CA%B5%CF%D6%B6%C1%C8%A1%BC%C6%CB%E3%BB%FA%C3%FB现有一设计要求:以这个作蓝本的客户端,写一个服务端,呼叫的声音在服务端播放,怎么实现
#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\桌面\前台呼叫.kxf
$Form1 = GUICreate("网吧前台呼叫", 536, 221, 192, 124)
GUISetBkColor(0x6B79B8)
$Group1 = GUICtrlCreateGroup("呼叫窗口", 8, 8, 249, 201)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Edit1 = GUICtrlCreateEdit("", 152, 48, 97, 25, BitOR($ES_CENTER,$ES_AUTOVSCROLL,$ES_AUTOHSCROLL))
GUICtrlSetFont(-1, 14, 800, 0, "宋体")
GUICtrlSetColor(-1, 0xFF0000)
$Label1 = GUICtrlCreateLabel("输入呼叫机号:", 16, 48, 132, 32)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("呼叫网管(F1)", 16, 136, 97, 41, BitOR($BS_DEFPUSHBUTTON,$BS_CENTER), $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 400, 0, "宋体")
$Button2 = GUICtrlCreateButton("呼叫服务员(F2)", 127, 136, 121, 41, BitOR($BS_DEFPUSHBUTTON,$BS_CENTER), $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 12, 400, 0, "宋体")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("前台服务", 268, 7, 249, 201)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Button3 = GUICtrlCreateButton("▲ 请服务员到服务台", 280, 32, 209, 33, BitOR($BS_DEFPUSHBUTTON,$BS_LEFT,$BS_FLAT))
GUICtrlSetFont(-1, 10, 800, 0, "宋体")
$Button4 = GUICtrlCreateButton("▲ 请清洁工到服务台", 280, 72, 209, 33, $BS_LEFT)
GUICtrlSetFont(-1, 10, 800, 0, "宋体")
$Button5 = GUICtrlCreateButton("▲ 请网管到服务台", 280, 113, 209, 33, $BS_LEFT)
GUICtrlSetFont(-1, 10, 800, 0, "宋体")
$Button6 = GUICtrlCreateButton("▲", 280, 153, 209, 33, $BS_LEFT)
GUICtrlSetFont(-1, 10, 800, 0, "宋体")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
Dim $Form1_AccelTable = [["{F1}", $Button1],["{F2}", $Button2]]
GUISetAccelerators($Form1_AccelTable)
#EndRegion ### END Koda GUI section ###
Local $ClientName, $Speak
Local $AudioPath = @ScriptDir & "\"
;设置号码数组
For $i = 0 To 10
$Speak[$i] = $AudioPath & $i & ".wav"
Next
$Speak = $AudioPath & "100.wav"
$Speak = $AudioPath & "hao.wav"
$Speak = $AudioPath & "help.wav"
$Speak = $AudioPath & "呼叫服务员.wav"
$Speak = $AudioPath & "千.wav"
;呼叫网管
Func _Play($Num)
SoundPlay($Speak, 1)
;~Local $Play
$Num = _ReturnInt($Num)
$len = StringLen($Num)
If StringLen($Num) = 2 Or StringLen($Num) = 3 And StringRight($Num, 2) = "00" Then
_SpeakTenPlay($Num)
Else
For $i = 1 To $len
$s = StringMid($Num, $i, 1)
_SpeakPlay($s, $len - $i)
Next
EndIf
SoundPlay($Speak, 1)
EndFunc ;==>_Play
;呼叫服务员
Func _Playserver($Num)
SoundPlay($Speak, 1)
;~Local $Play
$Num = _ReturnInt($Num)
$len = StringLen($Num)
If StringLen($Num) = 2 Or StringLen($Num) = 3 And StringRight($Num, 2) = "00" Then
_SpeakTenPlay($Num)
Else
For $i = 1 To $len
$s = StringMid($Num, $i, 1)
_SpeakPlay($s, $len - $i)
Next
EndIf
SoundPlay($Speak, 1)
EndFunc ;==>_Playserver
;10到和整百数字的发音
Func _SpeakTenPlay($s)
If $s = "10" Then
SoundPlay($Speak, 1)
ElseIf StringMid($s, 2, 2) = "00" Then
SoundPlay($Speak, 1)
SoundPlay($Speak, 1)
Else
SoundPlay($Speak, 1)
SoundPlay($Speak, 1)
EndIf
EndFunc ;==>_SpeakTenPlay
;其他任意1000以下数字的发音
Func _SpeakPlay($s, $Units)
Switch $Units
Case 0
If $s <> "0" Then
SoundPlay($Speak[$s], 1)
EndIf
Case 1
If $s = "0" Then
SoundPlay($Speak, 1)
Else
SoundPlay($Speak[$s], 1)
SoundPlay($Speak, 1)
EndIf
Case 2
SoundPlay($Speak[$s], 1)
SoundPlay($Speak, 1)
Case 3
SoundPlay($Speak[$s], 1)
SoundPlay($Speak, 1)
EndSwitch
EndFunc ;==>_SpeakPlay
Func _ReturnInt($Num)
Local $tmp
For $i = 1 To StringLen($Num)
If StringMid($Num, $i, 1) <> 0 Then
$tmp = StringRight($Num, StringLen($Num) - $i + 1)
ExitLoop
EndIf
Next
Return $tmp
EndFunc ;==>_ReturnInt
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$h = GUICtrlRead($Edit1)
If $h = 0 Then
MsgBox(64, "机号错误", "晕咯。。你还没有输入要呼叫的机号呢!")
Else
_Play($h)
Sleep(3500)
;GUICtrlSetData($Edit1,"")
EndIf
Case $Button2
$h = GUICtrlRead($Edit1)
If $h = 0 Then
MsgBox(64, "机号错误", "晕咯。。你还没有输入要呼叫的机号呢!")
Else
_Playserver($h)
Sleep(3500)
;GUICtrlSetData($Edit1,"")
EndIf
Case $Button3
SoundPlay(@ScriptDir&"\请服务员到服务台.wav")
Case $Button4
soundPlay(@ScriptDir&"\请清洁工到服务台.wav")
Case $Button5
soundPlay(@ScriptDir&"\请网管到服务台.wav")
Case $Button6
EndSwitch
WEnd
[ 本帖最后由 ufw119 于 2008-12-21 22:55 编辑 ] 没有顶呀。。。。MY GOD!! 好呀,收来看看先 涉及到 协议!这个你发布到交易区算了,还好些! 本帖最后由 rolaka 于 2010-1-22 19:32 编辑
核心就是端口监听和数据发送...
帮助里的例子就能做到...
你可以只接用udp协议局域网广播
这样东西其实没啥技术含量...局域网广播的例子 我重写的内局域网唤醒就可以当s了
http://autoitx.com/forum.php?mod=viewthread&tid=8299
楼上的楼上 挖坟的小心今天掉户口本! 看看再说...
页:
[1]