Version:
classextends TypedEventEmitter<MouseInputEvents, this>

MouseClass

class provides methods to emulate mouse input

typescript
class MouseClass extends TypedEventEmitter<MouseInputEvents, this>

Properties

NameTypeDescription
configMouseConfigConfig object for class(default: ...)

Methods

click

click(btn: Button): Promise<MouseClass>

clicks a mouse button

Parameters

btnButtonThe to click

Returns

Promise<MouseClass>

doubleClick

doubleClick(btn: Button): Promise<MouseClass>

performs a double click on a mouse button

Parameters

btnButtonThe to click

Returns

Promise<MouseClass>

drag

drag(path: Point[] | Promise<Point[]>, options?: MousePathActionOptions): Promise<MouseClass>

drags the mouse along a certain path
In summary, presses and holds the left mouse button, moves the mouse and releases the left button

Parameters

pathPoint[] | Promise<Point[]>The path of s to drag along
options?MousePathActionOptionsOptional action options, e.g. an abort signal to cancel drag

Returns

Promise<MouseClass>

getPosition

getPosition(): Promise<Point>

returns a representing the current mouse position

Returns

Promise<Point>

leftClick

leftClick(): Promise<MouseClass>

performs a click with the left mouse button

Returns

Promise<MouseClass>

move

move(path: Point[] | Promise<Point[]>, movementType: EasingFunction = linear, options?: MousePathActionOptions): Promise<MouseClass>

moves the mouse cursor along a given path of s, according to a movement type

Parameters

pathPoint[] | Promise<Point[]>Array of s to follow
movementTypeEasingFunctionDefines the type of mouse movement. Would allow to configured acceleration etc. (Default: , no acceleration)
options?MousePathActionOptionsOptional action options, e.g. an abort signal to cancel movement

Returns

Promise<MouseClass>

pressButton

pressButton(btn: Button): Promise<MouseClass>

presses and holds a mouse button

Parameters

btnButtonThe to press and hold

Returns

Promise<MouseClass>

releaseButton

releaseButton(btn: Button): Promise<MouseClass>

releases a mouse button previously pressed via

Parameters

btnButtonThe to release

Returns

Promise<MouseClass>

rightClick

rightClick(): Promise<MouseClass>

performs a click with the right mouse button

Returns

Promise<MouseClass>

scrollDown

scrollDown(amount: number): Promise<MouseClass>

scrolls down for a given amount of "steps"
Please note that the actual scroll distance of a single "step" is OS dependent

Parameters

amountnumberThe amount of "steps" to scroll

Returns

Promise<MouseClass>

scrollLeft

scrollLeft(amount: number): Promise<MouseClass>

scrolls left for a given amount of "steps"
Please note that the actual scroll distance of a single "step" is OS dependent

Parameters

amountnumberThe amount of "steps" to scroll

Returns

Promise<MouseClass>

scrollRight

scrollRight(amount: number): Promise<MouseClass>

scrolls right for a given amount of "steps"
Please note that the actual scroll distance of a single "step" is OS dependent

Parameters

amountnumberThe amount of "steps" to scroll

Returns

Promise<MouseClass>

scrollUp

scrollUp(amount: number): Promise<MouseClass>

scrolls up for a given amount of "steps"
Please note that the actual scroll distance of a single "step" is OS dependent

Parameters

amountnumberThe amount of "steps" to scroll

Returns

Promise<MouseClass>

setPosition

setPosition(target: Point | Promise<Point>): Promise<MouseClass>

instantly moves the mouse cursor to a given

Parameters

targetPoint | Promise<Point>to move the cursor to

Returns

Promise<MouseClass>

Was this page helpful?