找回密码
 加入
搜索
查看: 2492|回复: 5

下面源码改成S/C(有服务端和客户端模式)

[复制链接]
发表于 2008-12-21 22:52:21 | 显示全部楼层 |阅读模式
参考这里的代码修改成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 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2008-12-23 22:16:29 | 显示全部楼层
没有顶呀。。。。MY GOD!!
发表于 2010-1-22 17:06:30 | 显示全部楼层
好呀,收来看看先

评分

参与人数 1金钱 -1 收起 理由
afan -1

查看全部评分

发表于 2010-1-22 17:15:55 | 显示全部楼层
涉及到 协议!这个你发布到交易区算了,还好些!
发表于 2010-1-22 19:27:06 | 显示全部楼层
本帖最后由 rolaka 于 2010-1-22 19:32 编辑

核心就是端口监听和数据发送...

帮助里的例子就能做到...

你可以只接用udp协议局域网广播


这样东西其实没啥技术含量...局域网广播的例子 我重写的内局域网唤醒就可以当s了
http://autoitx.com/forum.php?mod=viewthread&tid=8299

楼上的楼上 挖坟的小心今天掉户口本!

评分

参与人数 1金钱 +10 收起 理由
afan + 10

查看全部评分

发表于 2010-1-23 07:44:34 | 显示全部楼层
看看再说...
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-22 14:34 , Processed in 0.086399 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表