GetClickablePoint() public method

public GetClickablePoint ( ) : System.Point
return System.Point
Example #1
0
        public static void MouseClick(AutomationElement element)
        {
            element.ScrollToIfPossible();
            element.SetFocus();

            var clickablePoint = element.GetClickablePoint();
            Cursor.Position = new System.Drawing.Point((int)clickablePoint.X, (int)clickablePoint.Y);
            mouse_event(MOUSEEVENTLF_LEFTDOWN, 0, 0, 0, 0);
            mouse_event(MOUSEEVENTLF_LEFTUP, 0, 0, 0, 0);
        }
Example #2
0
 internal void DragDropFileTo(FileInfo file, AutomationElement el)
 {
     Start(file.DirectoryName);
     ListUiItem fileInExplorer;
     fileInExplorer = GetFile(file.Name);
     Mouse.MoveTo(fileInExplorer.ClickablePoint);
     Mouse.Down(MouseButton.Left);
     Minimize();
     Mouse.MoveTo(el.GetClickablePoint().Convert());
     Mouse.Up(MouseButton.Left);
 }
Example #3
0
File: Mouse.cs Project: sohma/uia
 private static Point Center(AutomationElement element)
 {
     try
     {
         return element.GetClickablePoint();
     }
     catch (Exception)
     {
         return element.Current.BoundingRectangle.Center();
     }
 }
Example #4
0
        private static void ClickControl(AutomationElement control)
        {

            try
            {
                AutoItX3Lib.AutoItX3 at = new AutoItX3Lib.AutoItX3();

                System.Windows.Point clickpoint1 = control.GetClickablePoint();
                Console.WriteLine("Got clickable Points ");
                double x = clickpoint1.X;
                double y = clickpoint1.Y;
                int x1 = Convert.ToInt32(x);
                int y1 = Convert.ToInt32(y);

                at.MouseMove(x1, y1, -1);
                try
                {
                    at.MouseClick("LEFT", x1, y1, 1);

                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }

            }
            catch (Exception ex)
            {

                throw new Exception("error on getclickablepoints :" + ex.Message);

            }
        }
Example #5
0
 public static void AutomationElementGetClickablePoint(AutomationElement element)
 {
     Dump("GetClickablePoint()", true, element);
     try
     {
         Point obj = element.GetClickablePoint();
     }
     catch (Exception exception)
     {
         VerifyException(element, exception, 
             typeof(ElementNotAvailableException),
             typeof(NoClickablePointException)
         );
     }
 }
Example #6
0
 /// <summary>
 /// Move the mouse to an element and click on it.  The primary mouse button will be used
 /// this is usually the left button except if the mouse buttons are swaped.
 /// </summary>
 /// <param name="el">The element to click on</param>
 /// <exception cref="NoClickablePointException">If there is not clickable point for the element</exception>
 /// 
 /// <outside_see conditional="false">
 /// This API does not work inside the secure execution environment.
 /// <exception cref="System.Security.Permissions.SecurityPermission"/>
 /// </outside_see>
 public static void MoveToAndClick( AutomationElement el )
 {
     if (el == null)
     {
         throw new ArgumentNullException("el");
     }
     MoveToAndClick(el.GetClickablePoint());
 }
Example #7
0
 private static void DoubleClick(AutomationElement element)
 {
     Point p = element.GetClickablePoint();
     MoveToAndDoubleClick(p);
 }
Example #8
0
        private static void Click(AutomationElement element)
        {
            try
            {
                Point p = element.GetClickablePoint();
                MoveToAndClick(p);
            }
            catch (Exception ex)
            {

            }
        }
Example #9
0
        internal void DragDropMultipleFilesTo(string[] files, string folder, AutomationElement el)
        {
            var dir = FileLocator.LocateFolder(folder);
            Start(dir.FullName);
            ClickFile(files[0]);
            Keyboard.Press(Key.Ctrl);
            for (int i = 1; i < files.Count() - 1; i++) {
                ClickFile(files[i]);
            }
            var fileInExplorer = GetFile(files.Last());
            Mouse.MoveTo(fileInExplorer.ClickablePoint);
            Mouse.Down(MouseButton.Left);
            Keyboard.Release(Key.Ctrl);

            Minimize();
            Mouse.MoveTo(el.GetClickablePoint().Convert());
            Mouse.Up(MouseButton.Left);
        }
Example #10
0
        /// <summary>
        /// Moves or copies (taking the default behavior) one or more items in solution explorer to 
        /// the destination using the mouse.
        /// </summary>
        private static void DragAndDrop(AutomationElement destination, params AutomationElement[] source) {
            SelectItemsForDragAndDrop(source);

            try {
                Mouse.MoveTo(destination.GetClickablePoint());
            } finally {
                Mouse.Up(MouseButton.Left);
            }
        }
 /// <summary>
 /// Click Automation Element object
 /// </summary>
 /// <param name="automationElement">Automation Element object</param>
 /// <param name="leftOrRight">mouse button option :left / right</param>
 /// <returns>successed 1, unsuccesse 0</returns>
 public int ClickablePoint(AutomationElement automationElement, string leftOrRight)
 {
     try
     {
         System.Windows.Point ClickablePoint = automationElement.GetClickablePoint();
         this.MouseClick((int)ClickablePoint.X, (int)ClickablePoint.Y, leftOrRight);
         return 1;
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return 0;
     }
 }
 private void RightClickControl(AutomationElement control)
 {
     try
     {
         logTofile(_eLogPtah, "Inside Right click method");
         System.Windows.Point clickpoint1 = control.GetClickablePoint();
         double x = clickpoint1.X;
         double y = clickpoint1.Y;
         int x1 = Convert.ToInt32(x);
         int y1 = Convert.ToInt32(y);
         logTofile(_eLogPtah, "Clickable points " + x1 + " " + y1);
         at.MouseClick("RIGHT", x1, y1, 1);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        private void ClickControl(AutomationElement control)
        {
            logTofile(_eLogPtah, "ClickControl: outside of try");
            try
            {

                logTofile(_eLogPtah, "Inside Left click method control type is : " + control.Current.LocalizedControlType);
                System.Windows.Point clickpoint1 = control.GetClickablePoint();
                logTofile(_eLogPtah, "Got clickable Points ");
                double x = clickpoint1.X;
                double y = clickpoint1.Y;
                int x1 = Convert.ToInt32(x);
                int y1 = Convert.ToInt32(y);
                logTofile(_eLogPtah, "clickable Points " + x1.ToString() + " " + y1.ToString());
                at.MouseMove(x1, y1, -1);
                try
                {
                    at.MouseClick("LEFT", x1, y1, 1);

                }
                catch (Exception e)
                {
                    logTofile(_eLogPtah, "error on mouseclick :" + e.Message);
                }

            }
            catch (Exception ex)
            {
                logTofile(_eLogPtah, "Erroring Line numner in ClickControl " + GetStacktrace(ex).ToString());
                throw new Exception("error on getclickablepoints :" + ex.Message);

            }
        }
        public static void MouseInvokeFromClickablePoint(AutomationElement elem)
        {
            var clickablePoint = elem.GetClickablePoint();

            Mouse.MoveTo(new System.Drawing.Point((int)clickablePoint.X, (int)clickablePoint.Y));

            if ( ! elem.Current.IsEnabled)
            {
                throw new InvalidOperationException("Element '" + GetIdOrName(elem) + "' cannot be clicked since IsEnabled=false");
            }

            Mouse.Click(MouseButton.Left);
        }
Example #15
0
 internal void DragDropFileTo(FileInfo file, AutomationElement el)
 {
     Start(file.DirectoryName);
     Maximize();
     WaitWhileBusy();
     ListBox("Items View").TrySetFocus();
     List<ListUiItem> files = GetAllFiles();
     ListUiItem fileInExplorer = GetFile(files, file.Name);
     fileInExplorer.SetFocus();
     Mouse.MoveTo(fileInExplorer.ClickablePoint);
     Mouse.Down(MouseButton.Left);
     Thread.Sleep(500);
     Mouse.MoveTo(new Point(100, 100)); //ensure start of mouse drag
     Thread.Sleep(500);
     Mouse.MoveTo(new Point(750, 500)); //trying to always move the cursor to an approximated center on a 1080p display, which is still within a 1366x768 display
     Thread.Sleep(500);
     Minimize();
     var centerElement = el.GetClickablePoint().Convert();
     Log.DebugFormat("Point to drag to x/y: {0}, {1}", centerElement.X, centerElement.Y);
     if (!(centerElement.X < 10 && centerElement.Y < 10)) //failsafe, for our tests it's better to keep the position of 750,500 than end up with 0,0
         Mouse.MoveTo(centerElement);
     Mouse.Up(MouseButton.Left);
 }
Example #16
0
 internal void DragDropMultipleFilesTo(string[] filenames, string folder, AutomationElement el)
 {
     var dir = FileLocator.LocateFolder(folder);
     Start(dir.FullName);
     Maximize();
     WaitWhileBusy();
     ListBox("Items View").TrySetFocus();
     List<ListUiItem> files = GetAllFiles();
     SelectFile(files, filenames[0]);
     Keyboard.Press(Key.Ctrl);
     for (int i = 1; i < filenames.Count() - 1; i++) {
         SelectFile(files, filenames[i]);
     }
     var fileInExplorer = GetFile(files, filenames.Last());
     Mouse.MoveTo(fileInExplorer.ClickablePoint);
     Mouse.Down(MouseButton.Left);
     Keyboard.Release(Key.Ctrl);
     Thread.Sleep(500);
     Mouse.MoveTo(new Point(100, 100)); //ensure start of mouse drag
     Thread.Sleep(500);
     Mouse.MoveTo(new Point(750, 500)); //trying to always move the cursor to an approximated center on a 1080p display, which is still within a 1366x768 display
     Thread.Sleep(500);
     Minimize();
     var centerElement = el.GetClickablePoint().Convert();
     Log.DebugFormat("Point to drag to x/y: {0}, {1}", centerElement.X, centerElement.Y);
     if (!(centerElement.X == 0 && centerElement.Y == 0)) //failsafe, for our tests it's better to keep the position of 750,500 than end up with 0,0
         Mouse.MoveTo(centerElement);
     Mouse.Up(MouseButton.Left);
 }
Example #17
0
        /// <summary>
        /// Moves one or more items in solution explorer to the destination using the mouse.
        /// </summary>
        internal static void CopyByMouse(AutomationElement destination, params AutomationElement[] source) {
            SelectItemsForDragAndDrop(source);

            try {
                try {
                    Keyboard.Press(Key.LeftCtrl);
                    Mouse.MoveTo(destination.GetClickablePoint());
                } finally {
                    Mouse.Up(MouseButton.Left);
                }
            } finally {
                Keyboard.Release(Key.LeftCtrl);
            }
        }