/// <summary> /// Executes a mouse move instruction /// </summary> /// <param name="instruction">instruction to execute</param> private void ExecuteMoveInstruction(MouseInstruction instruction) { try { Rectangle screenBounds = Screen.PrimaryScreen.Bounds; int x = int.Parse(instruction.Extras["x"]); int y = int.Parse(instruction.Extras["y"]); if ((x >= 0 && x <= screenBounds.Width) && (y >= 0 && y <= screenBounds.Height)) { Mouse.SetPosition(x, y); } } catch { } }
/// <summary> /// Executes a mouse click instruction /// </summary> /// <param name="instruction">instruction to execute</param> private void ExecuteClickInstruction(MouseInstruction instruction) { string buttonToClick = instruction.Extras["button"]; if (buttonToClick.Equals("LEFT")) { Mouse.Event(Mouse.MOUSE_EVENT_LEFTDOWN); Mouse.Event(Mouse.MOUSE_EVENT_LEFTUP); } else if (buttonToClick.Equals("RIGHT")) { Mouse.Event(Mouse.MOUSE_EVENT_RIGHTDOWN); Mouse.Event(Mouse.MOUSE_EVENT_RIGHTUP); } }