Show / Hide Table of Contents

Method mouse.move(+ 3 overloads)


Overload

Moves the cursor (mouse pointer) to the position x y relative to window w.

public static POINT move(wnd w, Coord x = default, Coord y = default, bool nonClient = false)
Parameters
w  (wnd)

Window or control.

x  (Coord)

X coordinate relative to the client area of w. Default - center. Examples: 10, ^10 (reverse), .5f (fraction).

y  (Coord)

Y coordinate relative to the client area of w. Default - center.

nonClient  (bool)

x y are relative to the window rectangle.

Returns
POINT

Cursor position in screen coordinates.

Exceptions
AuWndException
  • Invalid window.
  • The window is hidden. No exception if just cloaked, for example in another desktop; then on click will activate, which usually uncloaks. No exception if w is a control.
  • Other window-related failures.
ArgumentOutOfRangeException

The position is not in screen. No exception if option Relaxed is true (then moves to a screen edge).

AuException

Failed to move the cursor to that position. Some reasons:

  • The active window belongs to a process of higher UAC integrity level.
  • Another thread blocks or modifies mouse input (API BlockInput, mouse hooks, frequent API SendInput etc).
  • Some application called API ClipCursor. No exception if option Relaxed is true (then final cursor position is undefined).
InputDesktopException

Remarks

Uses opt.mouse: OMouse.MoveSpeed, OMouse.MoveSleepFinally, OMouse.Relaxed.


Overload(next)

Moves the cursor (mouse pointer) to the position x y relative to UI object obj.

public static void move(MObject obj, Coord x = default, Coord y = default)
Parameters
obj  (MObject)

Can be wnd, elm, uiimage, screen, RECT in screen, RECT in window, mouse.lastXY (true), mouse.xy (false)

x  (Coord)

X coordinate relative to obj. Default - center. Examples: 10, ^10 (reverse), .5f (fraction).

y  (Coord)

Y coordinate relative to obj. Default - center.

Exceptions
ArgumentOutOfRangeException

The position is not in screen. No exception if option Relaxed is true (then moves to a screen edge).

AuException

Failed to move the cursor to that position. Some reasons:

  • The active window belongs to a process of higher UAC integrity level.
  • Another thread blocks or modifies mouse input (API BlockInput, mouse hooks, frequent API SendInput etc).
  • Some application called API ClipCursor. No exception if option Relaxed is true (then final cursor position is undefined).
InputDesktopException
Exception

Other exceptions. Depends on obj type.

Remarks

Uses opt.mouse: OMouse.MoveSpeed, OMouse.MoveSleepFinally, OMouse.Relaxed.


Overload(next)

Moves the cursor (mouse pointer) to the specified position in screen.

public static POINT move(Coord x, Coord y)
Parameters
x  (Coord)

X coordinate. Examples: 10, ^10 (reverse), .5f (fraction).

y  (Coord)

Y coordinate.

Returns
POINT

Normalized cursor position.

Exceptions
ArgumentOutOfRangeException

The position is not in screen. No exception if option Relaxed is true (then moves to a screen edge).

AuException

Failed to move the cursor to that position. Some reasons:

  • The active window belongs to a process of higher UAC integrity level.
  • Another thread blocks or modifies mouse input (API BlockInput, mouse hooks, frequent API SendInput etc).
  • Some application called API ClipCursor. No exception if option Relaxed is true (then final cursor position is undefined).
InputDesktopException

Remarks

Uses opt.mouse: OMouse.MoveSpeed, OMouse.MoveSleepFinally, OMouse.Relaxed.


Overload(top)

Moves the cursor (mouse pointer) to the specified position in screen.

public static void move(POINT p)
Parameters
p  (POINT)

Coordinates. Tip: To specify coordinates relative to the right, bottom, work area or a non-primary screen, use Coord.Normalize, like in the example.

Exceptions
ArgumentOutOfRangeException

The position is not in screen. No exception if option Relaxed is true (then moves to a screen edge).

AuException

Failed to move the cursor to that position. Some reasons:

  • The active window belongs to a process of higher UAC integrity level.
  • Another thread blocks or modifies mouse input (API BlockInput, mouse hooks, frequent API SendInput etc).
  • Some application called API ClipCursor. No exception if option Relaxed is true (then final cursor position is undefined).
InputDesktopException

Remarks

Uses opt.mouse: OMouse.MoveSpeed, OMouse.MoveSleepFinally, OMouse.Relaxed.

Examples

Save-restore mouse position.

var p = mouse.xy;
//...
mouse.move(p);

Use coordinates in the first non-primary screen.

mouse.move(Coord.Normalize(10, ^10, screen: screen.index(1))); //10 from left, 10 from bottom