参考这里的代码修改成http://www.autoitx.com/forum.php ... 6%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[2][2] = [["{F1}", $Button1],["{F2}", $Button2]]
GUISetAccelerators($Form1_AccelTable)
#EndRegion ### END Koda GUI section ###
Local $ClientName, $Speak[20]
Local $AudioPath = @ScriptDir & "\"
;设置号码数组
For $i = 0 To 10
$Speak[$i] = $AudioPath & $i & ".wav"
Next
$Speak[11] = $AudioPath & "100.wav"
$Speak[12] = $AudioPath & "hao.wav"
$Speak[13] = $AudioPath & "help.wav"
$Speak[14] = $AudioPath & "呼叫服务员.wav"
$Speak[15] = $AudioPath & "千.wav"
;呼叫网管
Func _Play($Num)
SoundPlay($Speak[12], 1)
;~ Local $Play[4]
$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[13], 1)
EndFunc ;==>_Play
;呼叫服务员
Func _Playserver($Num)
SoundPlay($Speak[12], 1)
;~ Local $Play[4]
$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[14], 1)
EndFunc ;==>_Playserver
;10到和整百数字的发音
Func _SpeakTenPlay($s)
If $s = "10" Then
SoundPlay($Speak[10], 1)
ElseIf StringMid($s, 2, 2) = "00" Then
SoundPlay($Speak[StringLeft($s, 1)], 1)
SoundPlay($Speak[11], 1)
Else
SoundPlay($Speak[10], 1)
SoundPlay($Speak[StringMid($s, 2, 1)], 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[0], 1)
Else
SoundPlay($Speak[$s], 1)
SoundPlay($Speak[10], 1)
EndIf
Case 2
SoundPlay($Speak[$s], 1)
SoundPlay($Speak[11], 1)
Case 3
SoundPlay($Speak[$s], 1)
SoundPlay($Speak[15], 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 编辑 ] |