Show / Hide Table of Contents

Method wnd.Focus


Overload

Sets the keyboard input focus to this control. Also activates its top-level parent window (see wnd.Activate).

public void Focus()
Exceptions
AuWndException
  • Invalid handle.
  • Disabled.
  • Failed to set focus.
  • Failed to activate parent window.
InputDesktopException

Remarks

The control can belong to any process/thread. With controls of this thread you can use the more lightweight function wnd.thisThread.focus. Works not with all windows. For example, does not work with Windows Store apps. Then use elm.Focus. Can instead focus a child control. For example, if this is a ComboBox, it will focus its child Edit control. Then does not throw exception. This can be control or top-level window. Top-level windows also can have focus. Fails when the target process is admin or uiAccess and this process isn't. See UAC.

See Also

wnd.focused
wnd.IsFocused
elm.Focus