Example #1
0
 public static void  ControlTVPressKey(string key)
 {
     Console.WriteLine(key, DateTime.Now.ToShortTimeString());
     if (key.Equals("O"))    // 打开播放器    指令实例:10|O
     {
         //MyDos.ExecDosInstructions(@"C:\Users\Public\IHomeFiles\5.flv");
         //MyDos.ExecDosInstructions(@"C:\Users\Public\IHomeFiles\4.flv");
         //MyDos.ExecDosInstructions(@"C:\Users\Public\IHomeFiles\3.flv");
         //MyDos.ExecDosInstructions(@"C:\Users\Public\IHomeFiles\2.flv");
         //MyDos.ExecDosInstructions(@"C:\Users\Public\IHomeFiles\1.flv");
         //System.Threading.Thread.Sleep(2000);
         //SendKeys.SendWait("%{Enter}");
         MyDos.ExecDosInstructions(@"PPTVAddressInfo.bat");
     }
     else if (key.Equals("C"))    // 关闭播放器      指令示例:10|C
     {
         MyDos.ExecDosInstructions(@"taskkill /f /im PPLive.exe");
     }
     else if (key.Equals("A"))    // 静音      指令示例:10|A
     {
         SendKeys.SendWait("{F7}");
     }
     else if (key.Equals("P"))    // 播放/暂停   指令实例:10|P
     {
         SendKeys.SendWait("^p");
     }
     else if (key.Equals("U"))    // 增大音量    指令实例:10|U
     {
         SendKeys.SendWait("{Up}");
     }
     else if (key.Equals("D"))    // 减小音量    指令示例:10|D
     {
         SendKeys.SendWait("{Down}");
     }
     else if (key.Equals("R"))    // 快进    指令示例:10|R
     {
         SendKeys.SendWait("{Right}");
     }
     else if (key.Equals("L"))    // 快退    指令示例:10|L
     {
         SendKeys.SendWait("{Left}");
     }
     else if (key.Equals("F"))   // 上一个节目    指令示例:10|F
     {
         SendKeys.SendWait("^{Left}");
     }
     else if (key.Equals("B"))   // 下一个节目    指令示例:~l0|B
     {
         SendKeys.SendWait("^{Right}");
     }
 }
Example #2
0
        // 关闭窗体
        private void close_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("您要退出 I - Home ? ", "温馨提示",
                                MessageBoxButtons.OKCancel,
                                MessageBoxIcon.Question) == DialogResult.OK)
            {
                string ip = GetIP();

                hx.Send_List("Signout|" + ip);
                hx.Leave_Out_HX();
                MyDos.ExecDosInstructions(@"taskkill /f /im Information Home PC.exe");
                server.Leave_Out();

                ExitNotifyIcon();
                AnimateWindow(this.Handle, 2000, AW_BLEND | AW_HIDE | AW_VER_NEGATIVE);
                //MyDos.ExecDosInstructions(@"taskkill /f /im Information Home PC.exe");
                Application.Exit();
            }
        }
Example #3
0
        // 当客户端发送消息时执行该函数,接收Socket中的数据
        public void ReceiveCallback(IAsyncResult ia)     //接收回调   ReceiveContent为接收数据
        {
            key = 0;
            StateObject _so = ia.AsyncState as StateObject;

            _socket = _so.theSocket;

            if (Pattern == "File sharing")
            {
                try
                {
                    int n = _socket.EndReceive(ia);     // 接收到的字节数
                    ReceiveContent = Encoding.UTF8.GetString(_so.Buffer, 0, n);
                    Console.WriteLine(ReceiveContent, DateTime.Now.ToLongTimeString());
                    string[] type = ReceiveContent.Split('?');
                    if (type[0].Equals("size"))                   //获取数据大小
                    {
                        Console.WriteLine(type[0] + "+" + type[1], DateTime.Now.ToLongTimeString());
                        key = 1;
                        string findContent_Size = cmd.Exec(type[1]);
                        if (findContent_Size.Equals("HQNR"))                                 // 如果数据为Byte[]
                        {
                            int i = cmd.Get_Byte().Length;
                            SendCommand(i);
                        }
                        else if (findContent_Size.Equals("PMTS"))
                        {
                            SendCommand(cmd.Get_Byte());
                        }
                        else
                        {
                            byte[] buffer = System.Text.Encoding.UTF8.GetBytes(findContent_Size);     //如果是字符串
                            SendCommand(buffer.Length);                                               // 发送大小
                        }
                        Console.WriteLine("size+string" + findContent_Size, DateTime.Now.ToLongTimeString());
                    }
                    else if (type[0].Equals("play"))                           //跳转到屏幕传输
                    {
                        PlayBells.StartPlayMedia("DoorBell.wav");
                        key = 1;
                        if (MessageBox.Show("请求分享风景?", "温馨提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                        {
                            PlayBells.StopPlayMedia();
                            SendCommand("OK");
                            Pattern = "Scenic sharing";
                            Thread thread_show = new Thread(ShowShow);
                            thread_show.Start();
                            threadClose = new Thread(ShowClose);
                            threadClose.Start();
                        }
                        else
                        {
                            PlayBells.StopPlayMedia();
                            SendCommand("NO");
                        }
                    }
                    else if (type[0].Equals("doorbells"))
                    {
                        PlayBells.StartPlayMedia("DoorBell.wav");
                        key = 1;
                        if (MessageBox.Show("是否接受视频通话?", "客人来访", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                        {
                            PlayBells.StopPlayMedia();
                            SendCommand("OK");
                            Pattern = "Scenic sharing";
                            Thread thread_show = new Thread(ShowShow);//创建新线程
                            thread_show.Start();
                        }
                        else
                        {
                            PlayBells.StopPlayMedia();
                            SendCommand("NO");
                        }
                    }
                    else if (type[0].Equals("voice"))                           //跳转到屏幕传输
                    {
                        PlayBells.StartPlayMedia("DoorBell.wav");
                        key = 1;
                        if (MessageBox.Show("请求语音通话?", "温馨提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                        {
                            PlayBells.StopPlayMedia();
                            SendCommand("OK");
                            Pattern     = "Voice Calls";
                            threadVoice = new Thread(ShowVoice);//创建新线程
                            threadVoice.Start();
                        }
                        else
                        {
                            PlayBells.StopPlayMedia();
                            SendCommand("NO");
                        }
                    }
                    else if (type[0].Equals("data"))
                    {
                        key     = 1;
                        Pattern = "DataSharing";
                    }
                    else if (type[0].Equals(""))
                    {
                        return;
                    }
                    else                             //获取数据或执行功能
                    {
                        Console.WriteLine(type[0], DateTime.Now.ToLongTimeString());
                        findContent = cmd.Exec(type[0]);
                    }
                }
                catch (Exception ex)
                {
                }
                if (!findContent.Equals("wcz") && !findContent.Equals("HQNR") && !findContent.Equals("PMTS") && key == 0)
                {
                    Console.WriteLine("string" + findContent, DateTime.Now.ToLongTimeString());
                    SendCommand(findContent);                                               // 发送字符串
                    findContent = "";
                }
                else if (findContent.Equals("HQNR") && key == 0)
                {
                    SendCommand(cmd.Get_Byte());                                           // 发送byte[]
                    findContent = "";
                }
                ReceiveContent = "";
            }
            else if (Pattern == "Scenic sharing")
            {
                try
                {
                    int n = _socket.EndReceive(ia);//接收到的字节数
                    Console.WriteLine(n.ToString(), DateTime.Now.ToLongTimeString());
                    ReceiveContent = Encoding.UTF8.GetString(_so.Buffer, 0, n);
                    if (_so.Buffer == null || ReceiveContent == "|||***|||")
                    {
                        threadClose.Abort();
                        Pattern = "File sharing";
                        shareform.Close();
                    }
                    else
                    {
                        closei = 0;
                        Console.WriteLine("shenjing", DateTime.Now.ToLongTimeString());
                        byte[] buffer = new byte[n];
                        Image  im     = ChangeImageWithByte.BytToImg(_so.Buffer, n); // 位图和字符流之间的转换
                        shareform.Back_Image(im);
                    }
                }
                catch (Exception ex)
                {
                }
                ReceiveContent = "";
            }
            else if (Pattern == "Voice Calls")
            {
                MemoryStream stream = new MemoryStream();
                WavEncoder   wav    = new WavEncoder();
                try
                {
                    int n = _socket.EndReceive(ia);//接收到的字节数
                    stream.Write(_so.Buffer, 0, n);
                    ReceiveContent = Encoding.UTF8.GetString(_so.Buffer, 0, n);
                    if (_so.Buffer == null || ReceiveContent == "|||***|||")
                    {
                        Pattern = "File sharing";
                        Voice_t.Abort();
                        sharevoice.Close();
                    }
                    else if (ReceiveContent == "start")
                    {
                        sharevoice.threadvoi = new Thread(MyAudio.Send_Voice);
                        sharevoice.threadvoi.Start();
                        Voice_t.Abort();
                        sharevoice.Change();
                    }
                    else
                    {
                        sound.Stream = wav.Encode(stream);
                        //System.Threading.Thread.Sleep(50);
                        Voice_t = new Thread(new ThreadStart(sound.Play));
                        Voice_t.Start();
                    }
                }
                catch
                {
                }
                ReceiveContent = "";
            }
            else if (Pattern == "DataSharing")
            {
                //name = "哈哈.mp4";
                try
                {
                    int n = _socket.EndReceive(ia);//接收到的字节数
                    Console.WriteLine(n.ToString(), DateTime.Now.ToLongTimeString());
                    ReceiveContent = Encoding.UTF8.GetString(_so.Buffer, 0, n);
                    if (ReceiveContent != "|||***|||")
                    {
                        string[] data = ReceiveContent.Split('|');
                        if (data[0] == "FileName")
                        {
                            name = data[1];
                        }
                        else
                        {
                            writeFile(_so.Buffer, @"C:\Users\Public\IHomeFiles\" + name, n);
                            MyDos.ExecDosInstructions(@"C:\Users\Public\IHomeFiles\" + name);
                        }
                    }
                    else
                    {
                        Console.WriteLine("shareform.Close();", DateTime.Now.ToLongTimeString());
                        Pattern = "File sharing";
                        //shareform.Close();
                    }
                }
                catch (Exception ex)
                {
                }
                ReceiveContent = "";
            }
            // 继续接收
            _so           = new StateObject();
            _so.theSocket = _socket;
            try
            {
                _socket.BeginReceive(_so.Buffer, 0, _so.Buffer.Length, SocketFlags.None, new AsyncCallback(this.ReceiveCallback), _so);
            }
            catch (Exception ex)
            {
            }
        }
Example #4
0
 public static void Instructions(String instructions)
 {
     if (instructions.Equals("YYSB"))    // 语音识别
     {
         MyDos.ExecDosInstructions(@"%windir%\Speech\Common\sapisvr.exe -SpeechUX");
     }
     else if (instructions.Equals("FDJ"))    // 放大镜
     {
         MyDos.ExecDosInstructions(@"C:\Windows\system32\Magnify.exe");
     }
     else if (instructions.Equals("JSR"))    // 讲述人
     {
         MyDos.ExecDosInstructions(@"C:\Windows\system32\Narrator.exe");
     }
     else if (instructions.Equals("PMJP"))    // 屏幕键盘
     {
         MyDos.ExecDosInstructions(@"C:\Windows\system32\osk.exe");
     }
     else if (instructions.Equals("JSRW"))    // 结束当前活动任务
     {
         MyDos.ExecDosInstructions(@"CloseTASK.vbs");
     }
     else if (instructions.Equals("SDJSJ"))    // 锁定计算机
     {
         MyDos.ExecDosInstructions(@"%windir%\System32\rundll32.exe user32.dll,LockWorkStation");
     }
     else if (instructions.Equals("GJ"))    // 关机
     {
         MyDos.ExecDosInstructions(@"shutdown -s");
     }
     else if (instructions.Equals("CQ"))    // 快速重启
     {
         MyDos.ExecDosInstructions(@"shutdown -f");
     }
     else if (instructions.Equals("WEB"))    // 打开浏览器
     {
         MyDos.ExecDosInstructions(@"start explorer http://cn.bing.com/");
     }
     else if (instructions.Equals("HT"))    // 画图
     {
         MyDos.ExecDosInstructions(@"C:\Windows\system32\mspaint.exe");
     }
     else if (instructions.Equals("JSQ"))    // 计算器
     {
         MyDos.ExecDosInstructions(@"calc");
     }
     else if (instructions.Equals("LYJ"))    // 录音机
     {
         MyDos.ExecDosInstructions(@"SoundRecorder.exe");
     }
     else if (instructions.Equals("JSB"))    // 记事本
     {
         MyDos.ExecDosInstructions(@"notepad.exe");
     }
     else if (instructions.Equals("WMP"))    // windows media player
     {
         MyDos.ExecDosInstructions(@"C:\Program Files (x86)\Windows Media Player\wmplayer.exe");
     }
     else if (instructions.Equals("JTGJ"))    // 截图工具
     {
         MyDos.ExecDosInstructions(@"C:\Windows\system32\SnippingTool.exe");
     }
     else if (instructions.Equals("BQ"))    // 便签
     {
         MyDos.ExecDosInstructions(@"C:\Windows\system32\StikyNot.exe");
     }
     else if (instructions.Equals("BZJLQ"))    // 步骤记录器
     {
         MyDos.ExecDosInstructions(@"C:\Windows\system32\psr.exe");
     }
     else if (instructions.Equals("XZB"))    // 写字板
     {
         MyDos.ExecDosInstructions(@"C:\Program Files\Windows NT\Accessories\wordpad.exe");
     }
     else if (instructions.Equals("ZTDN"))    // 这台电脑
     {
         MyDos.ExecDosInstructions(@"explorer.exe");
     }
     else if (instructions.Equals("SXSRMB"))    // 数学输入面板
     {
         MyDos.ExecDosInstructions(@"C:\Program Files\Common Files\Microsoft Shared\Ink\mip.exe");
     }
     else if (instructions.Equals("CZHSM"))    // 传真和扫描
     {
         MyDos.ExecDosInstructions(@"C:\Windows\system32\WFS.exe");
     }
 }