Table of Contents

Class Mouse

Namespace
Ranorex
Assembly
Ranorex.Core.dll

Provides mouse actions and events.

public class Mouse
Inheritance
Mouse
Inherited Members

Constructors

Mouse()

public Mouse()

Properties

Cursor

Returns the currently displayed mouse cursor.

public static Cursor Cursor { get; }

Property Value

Cursor

The current mouse cursor.

CursorName

Gets the name of the current mouse Cursor. If the cursor is not a system cursor, but a custom cursor, the name is 'Custom' plus its Handle value.

public static string CursorName { get; }

Property Value

string

The name of the cursor.

DefaultClickTime

Gets ors sets the default time of a mouse click, i.e. the time elapsed between the mouse button being pressed (Down event) and released again (Up event).

public static Duration DefaultClickTime { get; set; }

Property Value

Duration

Exceptions

ArgumentOutOfRangeException

If the value is negative.

DefaultMoveTime

Gets or sets the default time it takes to move the mouse to a specified position.

public static Duration DefaultMoveTime { get; set; }

Property Value

Duration

Exceptions

ArgumentOutOfRangeException

If the value is negative.

DisableManualInputDuringActions

Disables or enables manual mouse input by the user while input actions are performed.

public static bool DisableManualInputDuringActions { get; set; }

Property Value

bool

Enabled

Gets or sets a value indicating whether physical mouse actions are enabled.

public static bool Enabled { get; set; }

Property Value

bool

Remarks

If the mouse is disabled, physical mouse movements will be ignored, i.e. they are not passed on to the system. However, the Mouse events (like Move) will still be raised with the SuppressMouseAction property of the event args set to true. To reenable specific mouse events, set the SuppressMouseAction of the event args to false.

MouseInterpolation

Gets or sets the current mouse interpolation function.

public static Mouse.MouseInterpolationFunction MouseInterpolation { get; set; }

Property Value

Mouse.MouseInterpolationFunction

Position

Gets or sets the current position of the mouse in screen coordinates (pixels).

public static Point Position { get; set; }

Property Value

Point

Methods

ButtonDown(MouseButtons)

Presses the specified mouse button.

public static void ButtonDown(MouseButtons buttons)

Parameters

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

ButtonUp(MouseButtons)

Releases the specified mouse button.

public static void ButtonUp(MouseButtons buttons)

Parameters

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

Click()

Clicks the left mouse button.

public static void Click()

Click(Element)

Clicks on the element with the left mouse button.

public static void Click(Element element)

Parameters

element Element

The element to click.

Click(Element, Duration)

Clicks on the element with the left mouse button.

public static void Click(Element element, Duration moveTime)

Parameters

element Element

The element to click.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(Element, Location)

Clicks on the element with the left mouse button at a specific location location.

public static void Click(Element element, Location location)

Parameters

element Element

The element to click.

location Location

The location to click at.

Click(Element, Location, Duration)

Clicks on the element at a specific location.

public static void Click(Element element, Location location, Duration moveTime)

Parameters

element Element

The element to click.

location Location

The location to click at.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(Element, Location, int, Duration)

Clicks on the element at a specific location, with the left mouse button, the specified number of times.

public static void Click(Element element, Location location, int times, Duration moveTime)

Parameters

element Element

The element to click.

location Location

The location to click at.

times int

The number of times to click.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(Element, int, Duration)

Clicks on the element with the left mouse button the specified number of times.

public static void Click(Element element, int times, Duration moveTime)

Parameters

element Element

The element to click.

times int

The number of times to click.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(Element, MouseButtons)

Clicks on the element with the specified mouse buttons.

public static void Click(Element element, MouseButtons buttons)

Parameters

element Element

The element to click.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

Click(Element, MouseButtons, Duration)

Clicks on the element with the specified mouse buttons.

public static void Click(Element element, MouseButtons buttons, Duration moveTime)

Parameters

element Element

The element to click.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(Element, MouseButtons, Location)

Clicks on the element with the specified mouse buttons at a specific location location.

public static void Click(Element element, MouseButtons buttons, Location location)

Parameters

element Element

The element to click.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

location Location

The location to click at.

Click(Element, MouseButtons, Location, Duration)

Clicks on the element with the specified mouse buttons at a given location.

public static void Click(Element element, MouseButtons buttons, Location location, Duration moveTime)

Parameters

element Element

The element to click.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

location Location

The location to click at.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(Element, MouseButtons, Location, int)

Clicks on the element with the specified mouse buttons at a given location the specified number of times.

public static void Click(Element element, MouseButtons buttons, Location location, int times)

Parameters

element Element

The element to click.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

location Location

The location to click at.

times int

The number of times to click.

Click(Element, MouseButtons, Location, int, Duration)

Clicks at the specified location relative to the element with the specified mouse buttons the specified number of times.

public static void Click(Element element, MouseButtons buttons, Location location, int times, Duration moveTime)

Parameters

element Element

The element to click.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

location Location

The location relative to the upper-left corner of the element to click on.

times int

The number of times to click.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(Element, MouseButtons, int)

Clicks on the element with the specified mouse buttons the specified number of times.

public static void Click(Element element, MouseButtons buttons, int times)

Parameters

element Element

The element to click.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

times int

The number of times to click.

Click(Element, MouseButtons, int, Duration)

Clicks on the element with the specified mouse buttons the specified number of times.

public static void Click(Element element, MouseButtons buttons, int times, Duration moveTime)

Parameters

element Element

The element to click.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

times int

The number of times to click.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(Point)

Clicks at point with the left mouse button.

public static void Click(Point point)

Parameters

point Point

The point to click on in screen coordinates (pixels).

Click(Point, Duration)

Clicks at point with the left mouse button.

public static void Click(Point point, Duration moveTime)

Parameters

point Point

The point to click on in screen coordinates (pixels).

moveTime Duration

The time after which the mouse should be at the specified position.

Click(Point, int, Duration)

Clicks at point with the left mouse button the specified number of times.

public static void Click(Point point, int times, Duration moveTime)

Parameters

point Point

The point to click on in screen coordinates (pixels).

times int

The number of times to click.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(Point, MouseButtons)

Clicks at point with the specified mouse buttons.

public static void Click(Point point, MouseButtons buttons)

Parameters

point Point

The point to click on in screen coordinates (pixels).

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

Click(Point, MouseButtons, Duration)

Clicks at point with the specified mouse buttons.

public static void Click(Point point, MouseButtons buttons, Duration moveTime)

Parameters

point Point

The point to click on in screen coordinates (pixels).

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(Point, MouseButtons, int, Duration)

Clicks at point with the specified mouse buttons the specified number of times.

public static void Click(Point point, MouseButtons buttons, int times, Duration moveTime)

Parameters

point Point

The point to click on in screen coordinates (pixels).

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

times int

The number of times to click.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(int, int)

Clicks at point with the left mouse button.

public static void Click(int x, int y)

Parameters

x int

The x screen coordinate (pixels) of the point to click on.

y int

The y screen coordinate (pixels) of the point to click on.

Click(int, int, Duration)

Clicks at point with the left mouse button.

public static void Click(int x, int y, Duration moveTime)

Parameters

x int

The x screen coordinate (pixels) of the point to click on.

y int

The y screen coordinate (pixels) of the point to click on.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(int, int, int, Duration)

Clicks at point with the left mouse button the specified number of times.

public static void Click(int x, int y, int times, Duration moveTime)

Parameters

x int

The x screen coordinate (pixels) of the point to click on.

y int

The y screen coordinate (pixels) of the point to click on.

times int

The number of times to click.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(int, int, MouseButtons)

Clicks at point with the specified mouse buttons.

public static void Click(int x, int y, MouseButtons buttons)

Parameters

x int

The x screen coordinate (pixels) of the point to click on.

y int

The y screen coordinate (pixels) of the point to click on.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

Click(int, int, MouseButtons, Duration)

Clicks at point with the specified mouse buttons.

public static void Click(int x, int y, MouseButtons buttons, Duration moveTime)

Parameters

x int

The x screen coordinate (pixels) of the point to click on.

y int

The y screen coordinate (pixels) of the point to click on.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(int, int, MouseButtons, int, Duration)

Clicks at point with the specified mouse buttons the specified number of times.

public static void Click(int x, int y, MouseButtons buttons, int times, Duration moveTime)

Parameters

x int

The x screen coordinate (pixels) of the point to click on.

y int

The y screen coordinate (pixels) of the point to click on.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

times int

The number of times to click.

moveTime Duration

The time after which the mouse should be at the specified position.

Click(MouseButtons)

Clicks the specified mouse buttons.

public static void Click(MouseButtons buttons)

Parameters

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

Click(MouseButtons, Duration)

Clicks the specified mouse buttons.

public static void Click(MouseButtons buttons, Duration clickTime)

Parameters

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

clickTime Duration

The time of a mouse click, i.e. the time elapsed between the mouse button being pressed (Down event) and released again (Up event).

Click(MouseButtons, int, Duration)

Clicks the specified mouse buttons the specified number of times.

public static void Click(MouseButtons buttons, int times, Duration clickTime)

Parameters

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

times int

The number of times to click.

clickTime Duration

The time of a mouse click, i.e. the time elapsed between the mouse button being pressed (Down event) and released again (Up event).

DoubleClick()

DoubleClicks the left mouse button.

public static void DoubleClick()

DoubleClick(Element)

DoubleClicks on the element with the left mouse button.

public static void DoubleClick(Element element)

Parameters

element Element

The element to click.

DoubleClick(Element, Duration)

DoubleClicks on the element with the left mouse button.

public static void DoubleClick(Element element, Duration moveTime)

Parameters

element Element

The element to click.

moveTime Duration

The time after which the mouse should be at the specified position.

DoubleClick(Element, Location)

DoubleClicks on the element with the left mouse button at a specific location location.

public static void DoubleClick(Element element, Location location)

Parameters

element Element

The element to click.

location Location

The location to click at.

DoubleClick(Element, Location, Duration)

DoubleClicks on the element at a specific location.

public static void DoubleClick(Element element, Location location, Duration moveTime)

Parameters

element Element

The element to click.

location Location

The location to click at.

moveTime Duration

The time after which the mouse should be at the specified position.

DoubleClick(Element, MouseButtons)

DoubleClicks on the element with the specified mouse buttons.

public static void DoubleClick(Element element, MouseButtons buttons)

Parameters

element Element

The element to click.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

DoubleClick(Element, MouseButtons, Duration)

DoubleClicks on the element with the specified mouse buttons.

public static void DoubleClick(Element element, MouseButtons buttons, Duration moveTime)

Parameters

element Element

The element to click.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

moveTime Duration

The time after which the mouse should be at the specified position.

DoubleClick(Element, MouseButtons, Location)

DoubleClicks on the element with the specified mouse buttons at a specific location location.

public static void DoubleClick(Element element, MouseButtons buttons, Location location)

Parameters

element Element

The element to click.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

location Location

The location to click at.

DoubleClick(Element, MouseButtons, Location, Duration)

DoubleClicks on the element with the specified mouse buttons at a given location.

public static void DoubleClick(Element element, MouseButtons buttons, Location location, Duration moveTime)

Parameters

element Element

The element to click.

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

location Location

The location to click at.

moveTime Duration

The time after which the mouse should be at the specified position.

DoubleClick(Point)

DoubleClicks at point with the left mouse button.

public static void DoubleClick(Point point)

Parameters

point Point

The point to click on in screen coordinates (pixels).

DoubleClick(Point, Duration)

DoubleClicks at point with the left mouse button.

public static void DoubleClick(Point point, Duration moveTime)

Parameters

point Point

The point to click on in screen coordinates (pixels).

moveTime Duration

The time after which the mouse should be at the specified position.

DoubleClick(Point, MouseButtons)

DoubleClicks at point with the specified mouse buttons.

public static void DoubleClick(Point point, MouseButtons buttons)

Parameters

point Point

The point to click on in screen coordinates (pixels).

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

DoubleClick(Point, MouseButtons, Duration)

DoubleClicks at point with the specified mouse buttons.

public static void DoubleClick(Point point, MouseButtons buttons, Duration moveTime)

Parameters

point Point

The point to click on in screen coordinates (pixels).

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

moveTime Duration

The time after which the mouse should be at the specified position.

DoubleClick(MouseButtons)

DoubleClicks the specified mouse buttons.

public static void DoubleClick(MouseButtons buttons)

Parameters

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

DoubleClick(MouseButtons, Duration)

DoubleClicks the specified mouse buttons.

public static void DoubleClick(MouseButtons buttons, Duration clickTime)

Parameters

buttons MouseButtons

A bit-wise combination of MouseButtons values that specify the mouse buttons for this action.

clickTime Duration

The time of a mouse click, i.e. the time elapsed between the mouse button being pressed (Down event) and released again (Up event).

GetCursorImage()

Returns an image of the current mouse Cursor.

public static Bitmap GetCursorImage()

Returns

Bitmap

An image of the current mouse cursor.

GetCursorImage(Cursor)

Returns an image of the cursor.

public static Bitmap GetCursorImage(Cursor cursor)

Parameters

cursor Cursor

A Cursor instance.

Returns

Bitmap

An image of the cursor.

MoveTo(Element)

Moves the mouse to the specified element.

public static void MoveTo(Element element)

Parameters

element Element

The element to move to.

MoveTo(Element, Duration)

Moves the mouse to the specified element.

public static void MoveTo(Element element, Duration moveTime)

Parameters

element Element

The element to move to.

moveTime Duration

The time after which the mouse should be at the specified position.

MoveTo(Element, Location)

Moves the mouse to the specified location in the element.

public static void MoveTo(Element element, Location location)

Parameters

element Element

The element to move to.

location Location

The location relative to the element to move to.

MoveTo(Element, Location, Duration)

Moves the mouse to the specified location in the element.

public static void MoveTo(Element element, Location location, Duration moveTime)

Parameters

element Element

The element to move to.

location Location

The location relative to the element to move to.

moveTime Duration

The time after which the mouse should be at the specified position.

Exceptions

RanorexException

If the location to move to is outside of the visible desktop.

MoveTo(Point)

Moves the mouse to the specified point.

public static void MoveTo(Point point)

Parameters

point Point

The point in screen coordinates (pixels).

MoveTo(Point, Duration)

Moves the mouse to the specified point.

public static void MoveTo(Point point, Duration moveTime)

Parameters

point Point

The point in screen coordinates (pixels).

moveTime Duration

The time after which the mouse should be at the specified position.

Exceptions

RanorexException

If the specified point is outside of the visible desktop.

MoveTo(Point, double)

Moves the mouse to the specified point.

public static void MoveTo(Point point, double pixelsPerSecond)

Parameters

point Point

The point in screen coordinates (pixels).

pixelsPerSecond double

Specifies the mouse speed in pixels moved per second.

MoveTo(int, int)

Moves the mouse to the specified point.

public static void MoveTo(int x, int y)

Parameters

x int

The x screen coordinate (pixels) of the point to move to.

y int

The y screen coordinate (pixels) of the point to move to.

MoveTo(int, int, Duration)

Moves the mouse to the specified point.

public static void MoveTo(int x, int y, Duration moveTime)

Parameters

x int

The x screen coordinate (pixels) of the point to move to.

y int

The y screen coordinate (pixels) of the point to move to.

moveTime Duration

The time after which the mouse should be at the specified position.

MoveTo(int, int, double)

Moves the mouse to the specified point.

public static void MoveTo(int x, int y, double pixelsPerSecond)

Parameters

x int

The x screen coordinate (pixels) of the point to move to.

y int

The y screen coordinate (pixels) of the point to move to.

pixelsPerSecond double

Specifies the mouse speed in pixels moved per second.

ScrollHorizontalWheel(double)

Scrolls the horizontal mouse wheel.

public static void ScrollHorizontalWheel(double characters)

Parameters

characters double

The number of characters to scroll. A positive value indicates that the wheel is rotated to the right; a negative value indicates that the wheel is rotated to the left.

Remarks

This method examines the Windows mouse settings to compute a value for the ScrollHorizontalWheel(int) method.

ScrollHorizontalWheel(int)

Scrolls the horizontal mouse wheel.

public static void ScrollHorizontalWheel(int delta)

Parameters

delta int

Specifies the amount of wheel movement; this value should be a multiple of MouseWheelScrollDelta. A positive value indicates that the wheel is rotated to the right; a negative value indicates that the wheel is rotated to the left.

ScrollWheel(double)

Scrolls the mouse wheel.

public static void ScrollWheel(double lines)

Parameters

lines double

The number of lines to scroll. A positive value indicates that the wheel is rotated forward, away from the user; a negative value indicates that the wheel is rotated backward, toward the user.

Remarks

This method examines the values of MouseWheelScrollLines and MouseWheelScrollDelta to compute a value for the ScrollWheel(int) method.

ScrollWheel(int)

Scrolls the mouse wheel.

public static void ScrollWheel(int delta)

Parameters

delta int

Specifies the amount of wheel movement; this value should be a multiple of MouseWheelScrollDelta. A positive value indicates that the wheel is rotated forward, away from the user; a negative value indicates that the wheel is rotated backward, toward the user.

Events

Down

Occurs when a mouse button is pressed.

public static event MouseEventHandler Down

Event Type

MouseEventHandler

HorizontalWheel

Occurs when the horizontal mouse wheel is scrolled.

public static event MouseEventHandler HorizontalWheel

Event Type

MouseEventHandler

Move

Occurs when the mouse is moved.

public static event MouseEventHandler Move

Event Type

MouseEventHandler

Up

Occurs when a mouse button is released.

public static event MouseEventHandler Up

Event Type

MouseEventHandler

Wheel

Occurs when the mouse wheel is scrolled.

public static event MouseEventHandler Wheel

Event Type

MouseEventHandler