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
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
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
Enabled
Gets or sets a value indicating whether physical mouse actions are enabled.
public static bool Enabled { get; set; }
Property Value
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
Position
Gets or sets the current position of the mouse in screen coordinates (pixels).
public static Point Position { get; set; }
Property Value
Methods
ButtonDown(MouseButtons)
Presses the specified mouse button.
public static void ButtonDown(MouseButtons buttons)
Parameters
buttonsMouseButtonsA 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
buttonsMouseButtonsA 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
elementElementThe element to click.
Click(Element, Duration)
Clicks on the element with the left mouse button.
public static void Click(Element element, Duration moveTime)
Parameters
elementElementThe element to click.
moveTimeDurationThe 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
Click(Element, Location, Duration)
Clicks on the element at a specific location.
public static void Click(Element element, Location location, Duration moveTime)
Parameters
elementElementThe element to click.
locationLocationThe location to click at.
moveTimeDurationThe 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
elementElementThe element to click.
locationLocationThe location to click at.
timesintThe number of times to click.
moveTimeDurationThe 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
elementElementThe element to click.
timesintThe number of times to click.
moveTimeDurationThe 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
elementElementThe element to click.
buttonsMouseButtonsA 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
elementElementThe element to click.
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
moveTimeDurationThe 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
elementElementThe element to click.
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
locationLocationThe 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
elementElementThe element to click.
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
locationLocationThe location to click at.
moveTimeDurationThe 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
elementElementThe element to click.
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
locationLocationThe location to click at.
timesintThe 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
elementElementThe element to click.
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
locationLocationThe location relative to the upper-left corner of the element to click on.
timesintThe number of times to click.
moveTimeDurationThe 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
elementElementThe element to click.
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
timesintThe 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
elementElementThe element to click.
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
timesintThe number of times to click.
moveTimeDurationThe 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
pointPointThe 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
pointPointThe point to click on in screen coordinates (pixels).
moveTimeDurationThe 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
pointPointThe point to click on in screen coordinates (pixels).
timesintThe number of times to click.
moveTimeDurationThe 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
pointPointThe point to click on in screen coordinates (pixels).
buttonsMouseButtonsA 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
pointPointThe point to click on in screen coordinates (pixels).
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
moveTimeDurationThe 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
pointPointThe point to click on in screen coordinates (pixels).
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
timesintThe number of times to click.
moveTimeDurationThe 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
xintThe x screen coordinate (pixels) of the point to click on.
yintThe 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
xintThe x screen coordinate (pixels) of the point to click on.
yintThe y screen coordinate (pixels) of the point to click on.
moveTimeDurationThe 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
xintThe x screen coordinate (pixels) of the point to click on.
yintThe y screen coordinate (pixels) of the point to click on.
timesintThe number of times to click.
moveTimeDurationThe 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
xintThe x screen coordinate (pixels) of the point to click on.
yintThe y screen coordinate (pixels) of the point to click on.
buttonsMouseButtonsA 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
xintThe x screen coordinate (pixels) of the point to click on.
yintThe y screen coordinate (pixels) of the point to click on.
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
moveTimeDurationThe 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
xintThe x screen coordinate (pixels) of the point to click on.
yintThe y screen coordinate (pixels) of the point to click on.
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
timesintThe number of times to click.
moveTimeDurationThe 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
buttonsMouseButtonsA 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
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
clickTimeDurationThe 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
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
timesintThe number of times to click.
clickTimeDurationThe 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
elementElementThe element to click.
DoubleClick(Element, Duration)
DoubleClicks on the element with the left mouse button.
public static void DoubleClick(Element element, Duration moveTime)
Parameters
elementElementThe element to click.
moveTimeDurationThe 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
DoubleClick(Element, Location, Duration)
DoubleClicks on the element at a specific location.
public static void DoubleClick(Element element, Location location, Duration moveTime)
Parameters
elementElementThe element to click.
locationLocationThe location to click at.
moveTimeDurationThe 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
elementElementThe element to click.
buttonsMouseButtonsA 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
elementElementThe element to click.
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
moveTimeDurationThe 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
elementElementThe element to click.
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
locationLocationThe 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
elementElementThe element to click.
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
locationLocationThe location to click at.
moveTimeDurationThe 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
pointPointThe 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
pointPointThe point to click on in screen coordinates (pixels).
moveTimeDurationThe 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
pointPointThe point to click on in screen coordinates (pixels).
buttonsMouseButtonsA 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
pointPointThe point to click on in screen coordinates (pixels).
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
moveTimeDurationThe 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
buttonsMouseButtonsA 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
buttonsMouseButtonsA bit-wise combination of MouseButtons values that specify the mouse buttons for this action.
clickTimeDurationThe 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
Returns
- Bitmap
An image of the
cursor.
MoveTo(Element)
Moves the mouse to the specified element.
public static void MoveTo(Element element)
Parameters
elementElementThe element to move to.
MoveTo(Element, Duration)
Moves the mouse to the specified element.
public static void MoveTo(Element element, Duration moveTime)
Parameters
elementElementThe element to move to.
moveTimeDurationThe 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
elementElementThe element to move to.
locationLocationThe 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
elementElementThe element to move to.
locationLocationThe location relative to the element to move to.
moveTimeDurationThe 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
pointPointThe point in screen coordinates (pixels).
MoveTo(Point, Duration)
Moves the mouse to the specified point.
public static void MoveTo(Point point, Duration moveTime)
Parameters
pointPointThe point in screen coordinates (pixels).
moveTimeDurationThe time after which the mouse should be at the specified position.
Exceptions
- RanorexException
If the specified
pointis outside of the visible desktop.
MoveTo(Point, double)
Moves the mouse to the specified point.
public static void MoveTo(Point point, double pixelsPerSecond)
Parameters
pointPointThe point in screen coordinates (pixels).
pixelsPerSeconddoubleSpecifies 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
xintThe x screen coordinate (pixels) of the point to move to.
yintThe 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
xintThe x screen coordinate (pixels) of the point to move to.
yintThe y screen coordinate (pixels) of the point to move to.
moveTimeDurationThe 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
xintThe x screen coordinate (pixels) of the point to move to.
yintThe y screen coordinate (pixels) of the point to move to.
pixelsPerSeconddoubleSpecifies the mouse speed in pixels moved per second.
ScrollHorizontalWheel(double)
Scrolls the horizontal mouse wheel.
public static void ScrollHorizontalWheel(double characters)
Parameters
charactersdoubleThe 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
deltaintSpecifies 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
linesdoubleThe 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
deltaintSpecifies 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
HorizontalWheel
Occurs when the horizontal mouse wheel is scrolled.
public static event MouseEventHandler HorizontalWheel
Event Type
Move
Occurs when the mouse is moved.
public static event MouseEventHandler Move
Event Type
Up
Occurs when a mouse button is released.
public static event MouseEventHandler Up
Event Type
Wheel
Occurs when the mouse wheel is scrolled.
public static event MouseEventHandler Wheel