System.Windows.Automation.AutomationElement.SetFocus C# (CSharp) Method

SetFocus() public method

public SetFocus ( ) : void
return void
        public void SetFocus()
        {
            try
            {
                this._obj.SetFocus();
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }

        }

Usage Example

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);
        }
All Usage Examples Of System.Windows.Automation.AutomationElement::SetFocus