bool client_PublishArrived(object sender, PublishArrivedArgs e) { /* * Console.WriteLine("Received Message"); * Console.WriteLine("Topic: " + e.Topic); * Console.WriteLine("Payload: " + e.Payload); * Console.WriteLine();*/ string sAction = string.Empty; string sDst = string.Empty; //{ "src":"BN83I6IIBX3QP1DS4Y8URO41P2VWOTY9","dst":"aaabbbccc_111222333","msg":"hello"} //{ "src":"K91NS8PPF1B7KLNI2VWGO0D49HOM524T","dst":"testid000001_testst000001","msg":"hello"} //{"src":"K91NS8PPF1B7KLNI2VWGO0D49HOM524T","dst":"testid000001_testst000001","msg":"start"} //{"src":"K91NS8PPF1B7KLNI2VWGO0D49HOM524T","dst":"testid000001_testst000001","msg":"prev"} //{"src":"K91NS8PPF1B7KLNI2VWGO0D49HOM524T","dst":"testid000001_testst000001","msg":"next"} message_recv = JsonHelper.DeserializeJsonToObject <MQTTMessage_Recv>(e.Payload.ToString()); sAction = message_recv.msg.ToString().ToLower(); sDst = message_recv.dst.ToString(); strSRC = message_recv.src.ToString(); bool isPPTRunning = CheckPPTISRunning(); //确保 sProceName 全局变量被赋值 if (strDst == sDst) { if (sAction == "hello") { if (!isPPTRunning) { SendState("0"); } else { //btnClose.Visible = true; if (ProcessHelper.ProcessIsFront(sProceName)) { SendState("3"); } else { SendState("1"); } } } else if (sAction == "start") { ProcessHelper.BringWindowToFrontNow(sProceName); InputSMLTR.SimulateKeyPress(VirtualKeyCode.F5); } else if (sAction == "prev") { ProcessHelper.BringWindowToFrontNow(sProceName); InputSMLTR.SimulateKeyPress(VirtualKeyCode.UP); } else if (sAction == "next") { ProcessHelper.BringWindowToFrontNow(sProceName); InputSMLTR.SimulateKeyPress(VirtualKeyCode.DOWN); } } return(true); }