public Task ParseMessageReceived(WebSocketReceiveResult result) { string messageReceived = Encoding.Default.GetString(new ArraySegment <byte>(buffer, 0, result.Count)); VirtualMouse.MouseCommand mc = VirtualMouse.JsonToMouseCommand(messageReceived); //Console.WriteLine("Parsing Command: " + mc); if (mc.command == "move") { mouse.Move(mc.x, mc.y); } else if (mc.command == "right_click") { mouse.RightClick(); } else if (mc.command == "left_click") { mouse.LeftClick(); } else if (mc.command == "left_down") { mouse.LeftDown(); } else if (mc.command == "left_up") { mouse.LeftUp(); } else if (mc.command == "right_down") { mouse.RightDown(); } else if (mc.command == "right_up") { mouse.RightUp(); } else if (mc.command == "touchpad_start") { mouse.TouchpadStart(mc.x, mc.y); } else if (mc.command == "touchpad_move") { mouse.TouchpadMove(mc.x, mc.y, (int)mc.extra); } else if (mc.command == "set_volume") { audio.SetVolume(mc.x); } else { return(Error()); } return(Success()); }
public void MouseMove() { const int x = 12; const int y = 456; m.Move(x, y); Assert.AreEqual(x, Cursor.Position.X); Assert.AreEqual(y, Cursor.Position.Y); }
private void hanldeRequest(String result) { if (result.Contains("MUp")) { VirtualMouse.Move(0, -10); } else if (result.Contains("MRight")) { str_response = "mr"; VirtualMouse.Move(10, 0); } else if (result.Contains("MDown")) { VirtualMouse.Move(0, 10); } else if (result.Contains("MLeft")) { VirtualMouse.Move(-10, 0); } else if (result.Contains("MRClick")) { ServiceExample.VirtualMouse.RightClick(); } else if (result.Contains("MLClick")) { ServiceExample.VirtualMouse.LeftClick(); } else if (result.Contains("Shutdown")) { Shutdown_Restart_LogOff_Lock.shutdownBtn_Click(); } else if (result.Contains("Logoff")) { Shutdown_Restart_LogOff_Lock.logOffBtn_Click(); } else if (result.Contains("Restart")) { Shutdown_Restart_LogOff_Lock.restartBtn_Click(); } else if (result.Contains("Lock")) { Shutdown_Restart_LogOff_Lock.LockWorkStation(); } else if (result.Contains("Shutdown_a")) { Shutdown_Restart_LogOff_Lock.shotShutdownBtn_Click(); } else if (result.Contains("cmd_")) { String cmd_command = result.Substring(result.IndexOf("cmd_") + 4); // MessageBox.Show("CMd = " + cmd_command); try { Process.Start("" + cmd_command); } catch (Exception e) { // MessageBox.Show("Err = " + e.Message ); } } // else if (result.Contains("killp_")) // { // addToLog("killing request = : ----" + result+"----"); // String pname = result.Substring(result.IndexOf("killp_") + 6, result.Length - result.IndexOf("killp_") + 6); // pname = pname.Trim(); // addToLog("killing pname = ----" + pname+"----"); // // MessageBox.Show("Pname = ." + pname+"."); // Process[] p_cmd = Process.GetProcessesByName("cmd"); // //addToLog("custom list retrived name as " + "cmd" + " = " + p_cmd.Length); // Process[] p_notepad = Process.GetProcessesByName("notepad"); // // addToLog("custom list retrived name as " + "notepad" + " = " + p_notepad.Length); // // Process[] ps = Process.GetProcessesByName(pname); // // addToLog("no of listitems retrived name as ----" + pname + "---- = " + ps.Length); // // MessageBox.Show("Count of processes having name - "+pname +" = " + ps.Length ); // foreach (Process p in p_notepad) // { // addToLog("killing process" ); // p.Kill(); // // MessageBox.Show("in for"); // } //// MessageBox.Show("OLD COunt = " + p_old.Length + "\n NEW COunt = " + p_new.Length); // } else if (result.Contains("getp")) { str_response = ""; Process[] pAll = Process.GetProcesses(); List <String> mList = new List <String>(); for (int i = 1; i < pAll.Length; i++) { mList.Add(pAll[i].ProcessName); } mList.Sort(); str_response = pAll[0].ProcessName + ""; for (int i = 1; i < mList.Count; i++) { str_response = str_response + "" + "@#" + mList[i]; } // MyProcess p1 = new MyProcess("process1"); //JsonArray jsonArray = new JsonArray(); //jsonArray.Add(JsonValue.CreateNumberValue(116)); //jsonArray.Add(JsonValue.CreateNumberValue(3.14159)); //jsonArray.Add(JsonValue.CreateBooleanValue(true)); //jsonArray.Add(JsonValue.CreateStringValue("abc")); //string jsonString = jsonArray.Stringify(); } else { addToLog("in else "); } }