ClassMouse
Mouse events class.
Definition
Namespace:ArtOfTest.WebAii.Win32
Assembly:ArtOfTest.WebAii.dll
Syntax:
public class Mouse
Inheritance: objectMouse
Fields
CLICK_DELAY
Default number of ms to hold the mouse down for when we click
WHEEL_DELTA
Mouse wheel delta.
Properties
MouseMoveIntervalTime
Gets/Sets the mouse interval time between mouse move intervals. The default is set at 15msec. Typically you don't need to change this. If you want to configure the speed of the mouse move, use the Settings.SimulatedMouseMoveSpeed.
Methods
CalculateOffset(Rectangle, Point, OffsetReference)
Calculates the offset from the rectangles given a reference.
Declaration
public static Point CalculateOffset(Rectangle rectangle, Point offset, OffsetReference reference)
Parameters
rectangle
The rectangle.
offset
The offset.
reference
The offset reference type.
Returns
The adjusted point.
Click(MouseClickType, Point)
Simulate a mouse event (Target as a point object)
Declaration
public void Click(MouseClickType clickType, Point pointToClick)
Parameters
clickType
The type of the click mouse to simulate.
pointToClick
The point to click.
Click(MouseClickType, Rectangle)
Simulate a mouse event (Target a rectangle). Will click absolute center of target rectangle.
Declaration
public void Click(MouseClickType clickType, Rectangle target)
Parameters
clickType
The type of the click mouse to simulate.
target
The target rectangle to click the center for.
Click(MouseClickType, Rectangle, Point, OffsetReference)
Simulate a mouse event (Target as a rectangle with offset)
Declaration
public void Click(MouseClickType clickType, Rectangle target, Point offset, OffsetReference reference)
Parameters
clickType
The type of the click mouse to simulate.
target
The target rectangle.
offset
The offset in X/Y (negatives represents opposite direction).
Keep these in mind when calculating the offset from a reference point.
</remarks>
reference
The reference point to offset within the rectangle.
Click(MouseClickType, Rectangle, Point, OffsetReference, ActionPointUnitType)
Simulate a mouse event (Target as a rectangle with offset)
Declaration
public void Click(MouseClickType clickType, Rectangle target, Point offset, OffsetReference reference, ActionPointUnitType unitType)
Parameters
clickType
The type of the click mouse to simulate.
target
The target rectangle.
offset
The offset in X/Y (negatives represents opposite direction). When unit type is set to percentage X offset represents percentage of target width and Y offset represents percentage of target height
Keep these in mind when calculating the offset from a reference point.
</remarks>
reference
The reference point to offset within the rectangle.
unitType
Offset unit type.
Click(MouseClickType, int, int)
Simulate a mouse event.
Declaration
public void Click(MouseClickType clickType, int x, int y)
Parameters
clickType
The type of the click mouse to simulate.
x
Absolute X coordinate to click on.
y
Absolute Y coordinate to click on.
Click(MouseClickType, int, int, int)
Simulate a mouse event.
Declaration
protected virtual void Click(MouseClickType clickType, int x, int y, int wheelDelta)
Parameters
clickType
The type of the click mouse to simulate.
x
Absolute X coordinate to click on.
y
Absolute Y coordinate to click on.
wheelDelta
If a Wheel click then the wheel's turn delta, else ignored
DetectHotSpot(Rectangle, Cursor, int)
Given a rectangle and optionally a cursor, this function will detect the cursor change
Declaration
public virtual Point DetectHotSpot(Rectangle rectangle, Cursor hotSpotCursor, int radius)
Parameters
rectangle
The rectangle to you to detect the host spot within.
hotSpotCursor
The cursor that the hot spot will be. If null, the function will assume a hot spot if the cursor simple changes.
radius
The number of pixels from the center point to scan.
Returns
The actual point the ended up activating the cursor change.
DragDrop(Point, Point)
Simulate a mouse drag and drop.
DragDrop(Point, Point, int, int)
Simulate a mouse drag and drop.
Declaration
public void DragDrop(Point start, Point end, int intervals, int intervalDelay)
Parameters
start
The start drag point.
end
The end drop point.
intervals
Number of intervals for this dragdrop operation.
intervalDelay
The delay in msec. between each interval.
DragDrop(Rectangle, Point, OffsetReference, Rectangle, Point, OffsetReference)
Simulate a mouse drag and drop.
Declaration
public void DragDrop(Rectangle startTarget, Point startOffset, OffsetReference startReference, Rectangle endTarget, Point endOffset, OffsetReference endReference)
Parameters
startTarget
The start rectangle.
startOffset
The start offset.
startReference
The start offset reference.
endTarget
The end rectangle.
endOffset
The end offset.
endReference
The end offset reference.
DragDrop(Rectangle, Point, OffsetReference, Rectangle, Point, OffsetReference, int, int)
Simulate a mouse drag and drop.
Declaration
public void DragDrop(Rectangle startTarget, Point startOffset, OffsetReference startReference, Rectangle endTarget, Point endOffset, OffsetReference endReference, int intervals, int intervalDelay)
Parameters
startTarget
The start rectangle.
startOffset
The start offset.
startReference
The start offset reference.
endTarget
The end rectangle.
endOffset
The end offset.
endReference
The end offset reference.
intervals
Number of intervals for this dragdrop operation.
intervalDelay
The delay in msec. between each interval.
DragDrop(Rectangle, Rectangle)
Simulate a mouse drag and drop. (Uses center point of each rectangle)
DragDrop(Rectangle, Rectangle, int, int)
Simulate a mouse drag and drop. (Uses center point of each rectangle)
Declaration
public void DragDrop(Rectangle startTarget, Rectangle endTarget, int intervals, int intervalDelay)
Parameters
startTarget
Start target.
endTarget
End target.
intervals
Number of intervals for this dragdrop operation.
intervalDelay
The delay in msec. between each interval.
DragDrop(Rectangle, int, int, OffsetReference, Rectangle, int, int, OffsetReference)
Simulate a mouse drag and drop.
Declaration
public void DragDrop(Rectangle startTarget, int startOffsetX, int startOffsetY, OffsetReference startReference, Rectangle endTarget, int endOffsetX, int endOffsetY, OffsetReference endReference)
Parameters
startTarget
The start rectangle.
startOffsetX
The x start offset.
startOffsetY
The y start offset.
startReference
The start offset reference.
endTarget
The end rectangle.
endOffsetX
The x end offset.
endOffsetY
The y end offset.
endReference
The end offset reference.
DragDrop(Rectangle, int, int, OffsetReference, Rectangle, int, int, OffsetReference, int, int)
Simulate a mouse drag and drop.
Declaration
public void DragDrop(Rectangle startTarget, int startOffsetX, int startOffsetY, OffsetReference startReference, Rectangle endTarget, int endOffsetX, int endOffsetY, OffsetReference endReference, int intervals, int intervalDelay)
Parameters
startTarget
The start rectangle.
startOffsetX
The x start offset.
startOffsetY
The y start offset.
startReference
The start offset reference.
endTarget
The end rectangle.
endOffsetX
The x end offset.
endOffsetY
The y end offset.
endReference
The end offset reference.
intervals
Number of intervals for this dragdrop operation.
intervalDelay
The delay in msec. between each interval.
DragDrop(int, int, int, int)
Simulates a mouse drag and drop.
Declaration
public void DragDrop(int startX, int startY, int endX, int endY)
Parameters
startX
Absolute X coordinate to start the drag.
startY
Absolute Y coordinate to start the drag.
endX
Absolute X coordinate to do the drop.
endY
Absolute Y coordinate to do the drop.
DragDrop(int, int, int, int, int, int)
Simulates a mouse drag and drop.
Declaration
public virtual void DragDrop(int startX, int startY, int endX, int endY, int intervals, int intervalDelay)
Parameters
startX
Absolute X coordinate to start the drag.
startY
Absolute Y coordinate to start the drag.
endX
Absolute X coordinate to do the drop.
endY
Absolute Y coordinate to do the drop.
intervals
Number of intervals for this DragDrop operation.
intervalDelay
The delay in msec. between each interval.
GetCursorHandle()
Get the current cursor handle
Declaration
public virtual IntPtr GetCursorHandle()
Returns
The cursor handle.
Remarks
System.Windows.Forms.Cursor.Handle does not work. Seems like it is always cached.
GetDistance(Point, Point)
Gets the number of mouse move intervals depending on the current set speed and interval time. Any negative coordinates will be reset to zero automatically.
GetRelativeNumOfMouseMoveIntervals(Point, Point)
Gets the number of mouse move intervals depending on the current set speed and interval time.
GetRelativeNumOfMouseMoveIntervals(Rectangle, Point, OffsetReference, Rectangle, Point, OffsetReference)
Returns the relative number of mouse move intervals given a start/end locations.
Declaration
protected int GetRelativeNumOfMouseMoveIntervals(Rectangle startTarget, Point startOffset, OffsetReference startReference, Rectangle endTarget, Point endOffset, OffsetReference endReference)
Parameters
startTarget
Start rectangle.
startOffset
Start offset.
startReference
Start offset reference.
endTarget
End rectangle.
endOffset
End offset.
endReference
End offset reference.
Returns
The number of intervals
GetRelativeNumOfMouseMoveIntervals(Rectangle, Rectangle)
Gets the number of mouse move intervals depending on the current set speed and interval time. Uses the absolute centers of passed in rectangles.
GetRelativeNumOfMouseMoveIntervals(int)
Gets the number of mouse move intervals depending on the current set speed and interval time. DistanceInPixels(pixels) = NumOfIntervals(const) * IntervalTime(msec) * Speed(pixels/msec)
HoverOver(Point)
HoverOver (Target a point).
Declaration
public void HoverOver(Point pointToHoverOver)
Parameters
pointToHoverOver
Point to hover over.
HoverOver(Rectangle)
Hover over (Target the center of the target rectangle).
Declaration
public void HoverOver(Rectangle target)
Parameters
target
The target rectangle.
HoverOver(Rectangle, Point, OffsetReference)
Hover over (Target is a rectangle with an offset).
Declaration
public void HoverOver(Rectangle target, Point offset, OffsetReference reference)
Parameters
target
The target rectangle.
offset
The offset in X/Y (negatives represents opposite direction).
reference
The reference point to offset within the rectangle.
HoverOver(Rectangle, Point, OffsetReference, ActionPointUnitType)
Hover over (Target is a rectangle with an offset).
Declaration
public void HoverOver(Rectangle target, Point offset, OffsetReference reference, ActionPointUnitType unitType)
Parameters
target
The target rectangle.
offset
The offset in X/Y (negatives represents opposite direction). When unit type is set to percentage X offset represents percentage of target width and Y offset represents percentage of target height.
reference
The reference point to offset within the rectangle.
unitType
Offset unit type.
HoverOver(int, int)
Simulates a mouse hover over. Simply moves the mouse pointer over the X,Y passed in. Can also be used to move the mouse to a certain location.
MatchCursor(IntPtr)
Tests whether or not the current mouse handle matches a specified handle. Can be used to check if the current mouse cursor is a particular value.
Move(Point, Point)
Move the mouse from the start to the end location
Move(Point, Point, int, int)
Move the mouse from the start to the end location
Declaration
public void Move(Point start, Point end, int intervals, int intervalDelay)
Parameters
start
start point of the move.
end
end point of the move
intervals
Number of intervals for this Move operation.
intervalDelay
The delay in msec. between each interval.
Move(Rectangle, Point, OffsetReference, Rectangle, Point, OffsetReference)
Move the mouse from the start to the end location
Declaration
public void Move(Rectangle startTarget, Point startOffset, OffsetReference startReference, Rectangle endTarget, Point endOffset, OffsetReference endReference)
Parameters
startTarget
Move start rectangle.
startOffset
Move start offset.
startReference
Move start offsetReference
endTarget
Move end rectangle.
endOffset
Move end offset.
endReference
Move end offsetReference.
Move(Rectangle, Point, OffsetReference, Rectangle, Point, OffsetReference, int, int)
Move the mouse from the start to the end location
Declaration
public void Move(Rectangle startTarget, Point startOffset, OffsetReference startReference, Rectangle endTarget, Point endOffset, OffsetReference endReference, int intervals, int intervalDelay)
Parameters
startTarget
Move start rectangle.
startOffset
Move start offset.
startReference
Move start offsetReference
endTarget
Move end rectangle.
endOffset
Move end offset.
endReference
Move end offsetReference.
intervals
Number of intervals for this Move operation.
intervalDelay
The delay in msec. between each interval.
Move(Rectangle, Rectangle)
Move the mouse from the start to the end location
Move(Rectangle, Rectangle, int, int)
Move the mouse from the start to the end location
Declaration
public void Move(Rectangle start, Rectangle end, int intervals, int intervalDelay)
Parameters
start
Move start point.
end
Move end point.
intervals
Number of intervals for this Move operation.
intervalDelay
The delay in msec. between each interval.
Move(Rectangle, int, int, OffsetReference, Rectangle, int, int, OffsetReference)
Move the mouse from the start to the end location
Declaration
public void Move(Rectangle startTarget, int startOffsetX, int startOffsetY, OffsetReference startReference, Rectangle endTarget, int endOffsetX, int endOffsetY, OffsetReference endReference)
Parameters
startTarget
Move start rectangle.
startOffsetX
Move start offset x.
startOffsetY
Move start offset y.
startReference
Move start offsetReference
endTarget
Move end rectangle.
endOffsetX
Move end offset x.
endOffsetY
Move end offset y.
endReference
Move end offsetReference.
Move(Rectangle, int, int, OffsetReference, Rectangle, int, int, OffsetReference, int, int)
Move the mouse from the start to the end location
Declaration
public void Move(Rectangle startTarget, int startOffsetX, int startOffsetY, OffsetReference startReference, Rectangle endTarget, int endOffsetX, int endOffsetY, OffsetReference endReference, int intervals, int intervalDelay)
Parameters
startTarget
Move start rectangle.
startOffsetX
Move start offset x.
startOffsetY
Move start offset y.
startReference
Move start offsetReference
endTarget
Move end rectangle.
endOffsetX
Move end offset x.
endOffsetY
Move end offset y.
endReference
Move end offsetReference.
intervals
Number of intervals for this Move operation.
intervalDelay
The delay in msec. between each interval.
Move(int, int, int, int)
Move the mouse from the start to the end location
Move(int, int, int, int, int, int)
Move the mouse from the start to the end location
Declaration
public void Move(int startX, int startY, int endX, int endY, int intervals, int intervalDelay)
Parameters
startX
Move start X position.
startY
Move start Y position.
endX
Move end X position.
endY
Move end Y position.
intervals
Number of intervals for this Move operation.
intervalDelay
The delay in msec. between each interval.
TurnWheel(int, MouseWheelTurnDirection)
Move the mouse wheel by a certain delta
Declaration
public void TurnWheel(int delta, MouseWheelTurnDirection direction)
Parameters
delta
The delta to use.
direction
The direction to turn the mouse wheel in.