public static void ClickProbe(int n)
        {
            if (n < 1)
            {
                throw new ArgumentOutOfRangeException("Menu items' index start at 1");
            }
            int    xMul = (n - 1) % 3;
            bool   yAdd = (int)((n - 1) / 3) >= 1;
            int    x    = 100 + 250 * xMul;
            int    y    = 100 + (yAdd ? 150 : 0);
            String menu = WebHandling.GetMenuNumber();

            SecureClick(x, y);
            for (int i = 0; i < 100; i++)
            {
                Thread.Sleep(50);
                if (!menu.Equals(WebHandling.GetMenuNumber()))
                {
                    break;
                }
            }
            if (menu.Equals(WebHandling.GetMenuNumber()))
            {
                throw new Exception("Menu has not changed!");
            }
        }
            public static void ClickMenuItem(int n)
            {
                if (n < 1)
                {
                    throw new ArgumentOutOfRangeException("Menu items' index start at 1");
                }
                int x = 200;
                int y = 140 + 65 * (n - 1);

                SecureClick(x, y);
                String menu = WebHandling.GetMenuNumber();

                for (int i = 0; i < 100; i++)
                {
                    Thread.Sleep(50);
                    if (!menu.Equals(WebHandling.GetMenuNumber()))
                    {
                        break;
                    }
                }
                if (menu.Equals(WebHandling.GetMenuNumber()))
                {
                    throw new Exception("Menu has not changed!");
                }
            }
            /// <summary>
            /// Select which input field should be selected (1 -> 4, left -> right)
            /// </summary>
            /// <param name="n"></param>
            public static void SelectKeypadInput(int n)
            {
                if (n < 1)
                {
                    throw new ArgumentOutOfRangeException("Menu items' index start at 1");
                }
                String currentlySelected = WebHandling.GetPropertyFromURL("http://127.0.0.1:5000/pacific/symbols/enter_ip_selected_box", WebHandling.METHOD_GET, "value");

                if (!currentlySelected.Equals((n - 1).ToString()))
                {
                    Console.WriteLine("Changing selected input from {0} to {1}", currentlySelected, (n - 1));
                    SecureClick(210 + 100 * (n - 1), 50);
                    Thread.Sleep(100);
                }
                else
                {
                }
            }
        public static void SecureClick(int x, int y)
        {
            bool correct = false;

            if (prevPoint == null)
            {
                Console.WriteLine("PrevPoint == null, trying to click at: {0}, {1}", x, y);
                for (int i = 0; i < 3; i++)
                {
                    WebHandling.ResetCursor();
                    bool resetCursor = false;
                    for (int j = 0; j < 1000; j++)   //Max 1 second timeout
                    {
                        Thread.Sleep(1);
                        if (IsMouseCorrectPosition(0, 0))
                        {
                            resetCursor = true;
                            break;
                        }
                    }
                    if (resetCursor)
                    {
                        WebHandling.MoveMouseRelative(x, y);
                        int count = 0;
                        for (int j = 0; j < 1000; j++)       //Max 1 second timeout
                        {
                            Thread.Sleep(10);
                            if (IsMouseCorrectPosition(x, y))
                            {
                                if (count >= 3)
                                {
                                    correct = true;
                                    break;
                                }
                                count++;
                            }
                        }
                    }
                    if (correct)
                    {
                        break;
                    }
                }
                if (!correct)
                {
                    throw new Exception("Could not move mouse to absolute Position (" + x + ", " + y + ")");
                }
                WebHandling.ClickAtCursor();
                prevPoint = new CustomPoint(x, y);
            }
            else
            {
                int newX = x - prevPoint.GetX();
                int newY = y - prevPoint.GetY();
                //Console.WriteLine("newX: {0}, newY: {1}, x: {2}, y: {3}, prevX: {4}, prevY: {5}", newX, newY, x, y, prevPoint.GetX(), prevPoint.GetY());
                WebHandling.MoveMouseRelative(newX, newY);
                for (int j = 0; j < 1000; j++)       //Max 1 second timeout
                //Thread.Sleep(1);
                {
                    if (IsMouseCorrectPosition(x, y))
                    {
                        correct = true;
                        break;
                    }
                    else
                    {
                        //Console.WriteLine("Mouse is not in correct Position, should be: {0}, {1}  is: {2}, {3}", x, y, readX, readY);
                    }
                }
                if (!correct)
                {
                    throw new Exception("Could not move mouse to absolute Position (" + newX + ", " + newY + "), relative Position (" + x + ", " + y + ")");
                }
                WebHandling.ClickAtCursor();
                prevPoint = new CustomPoint(x, y);
            }
        }
 private static bool IsMouseCorrectPosition(int x, int y)
 {
     return(x.ToString().Equals(WebHandling.GetMouseX()) && y.ToString().Equals(WebHandling.GetMouseY()));
 }