Class MouseEvent<T extends AbstractMouseDestination>
- java.lang.Object
-
- org.dreambot.api.input.event.AbstractEvent
-
- org.dreambot.api.input.event.impl.mouse.type.AbstractMouseEvent
-
- org.dreambot.api.input.event.impl.mouse.MouseEvent<T>
-
- All Implemented Interfaces:
java.lang.Runnable
public class MouseEvent<T extends AbstractMouseDestination> extends AbstractMouseEvent
Mouse event that handles the full movement and click process based on the fields you pass in. You can use whatever implementation ofAbstractMouseDestination
that you need. These examples usePointDestination
Examples: To just move the mouse with no clicks, you would use
In order to drag with the left mouse button you'd use:MouseEvent<PointDestination> event = new MouseEvent<>(new PointDestination(100, 300), MouseMode.NONE, MouseButton.NULL); event.run();
The middle mouse button is the same but with MouseButton.MIDDLE_CLICK In order to click at your current position you can either use new PointDestination(Mouse.getPosition()) or you can pass in a null destination. This example will callMouseEvent<PointDestination> event = new MouseEvent<>(new PointDestination(100, 300), MouseMode.DRAG, MouseButton.LEFT_CLICK); event.run();
MouseAlgorithm.handleClick(MouseButton)
with the supplied mouse button (left click in this case)MouseEvent<PointDestination> event = new MouseEvent<>(null, MouseMode.FULL_CLICK, MouseButton.LEFT_CLICK); event.run();
-
-
Constructor Summary
Constructors Constructor Description MouseEvent(T destination)
Moves the mouse to the given destination Does not Click See implementations ofAbstractMouseDestination
MouseEvent(T destination, MouseMode mouseMode, MouseButton mouseButton)
Moves the mouse to the givenAbstractMouseDestination
if given one, does not move if null IfMouseMode
is notMouseMode.NONE
it will adjust behavior as requested.MouseEvent(T destination, MouseMode mouseMode, WheelMode wheelMode, Condition stop, long timeout)
CallsWheelEvent
's to scroll until the given stop condition is met or the timeout is reached
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Condition
completed()
AbstractCondition
used to determine if current event is complete.boolean
equals(java.lang.Object o)
Condition
failed()
AbstractCondition
used to determine if current event has failed.T
getDestination()
MouseButton
getMouseButton()
MouseMode
getMouseMode()
long
getTimeout()
Condition
getWheelCondition()
WheelMode
getWheelMode()
int
hashCode()
boolean
isCompleted()
boolean
isFailed()
void
run()
Runs the event.void
setCompleted(boolean completed)
void
setDestination(T destination)
void
setFailed(boolean failed)
void
setMouseButton(MouseButton mouseButton)
void
setMouseMode(MouseMode mouseMode)
void
setTimeout(long timeout)
void
setWheelCondition(Condition wheelCondition)
void
setWheelMode(WheelMode wheelMode)
java.lang.String
toString()
-
-
-
Constructor Detail
-
MouseEvent
public MouseEvent(T destination)
Moves the mouse to the given destination Does not Click See implementations ofAbstractMouseDestination
- Parameters:
destination
-AbstractMouseDestination
to use to move the mouse
-
MouseEvent
public MouseEvent(T destination, MouseMode mouseMode, MouseButton mouseButton)
Moves the mouse to the givenAbstractMouseDestination
if given one, does not move if null IfMouseMode
is notMouseMode.NONE
it will adjust behavior as requested. Please note, if you want it to send a full press, release, click at the end useMouseMode.FULL_CLICK
- Parameters:
destination
-AbstractMouseDestination
to use to move the mouse - if not null will assume mouse movementmouseMode
-MouseMode
mouse mode to determine the event types to use if it's not a basic move call. IfMouseMode.NONE
, only does regular move events. SeeMoveEvent
mouseButton
-MouseButton
button to use when clicking
-
MouseEvent
public MouseEvent(T destination, MouseMode mouseMode, WheelMode wheelMode, Condition stop, long timeout)
CallsWheelEvent
's to scroll until the given stop condition is met or the timeout is reached- Parameters:
destination
-AbstractMouseDestination
to use to move the mouse - if not null will assume mouse movementmouseMode
-MouseMode
mouse mode to determine the event types to use if it's not a basic move call. IfMouseMode.NONE
, only does regular move events. SeeMoveEvent
wheelMode
-WheelMode
for scrolling up or downstop
-Condition
for when to stop scrollingtimeout
- timeout in ms for when to stop scrolling if the condition is not met
-
-
Method Detail
-
run
public final void run()
Runs the event. DuringMouseMode.DRAG
we automatically add in the press and release events for your supplied button. You can useMouse.isMouseDragging()
to determine if the mouse is currently being dragged in yourMouseAlgorithm.handleMovement(AbstractMouseDestination)
-
completed
public Condition completed()
AbstractCondition
used to determine if current event is complete.- Overrides:
completed
in classAbstractMouseEvent
- Returns:
Condition
used to determine if current event has completed successfully.
-
failed
public Condition failed()
AbstractCondition
used to determine if current event has failed.- Overrides:
failed
in classAbstractMouseEvent
- Returns:
Condition
used to determine if current event has failed.
-
isCompleted
public boolean isCompleted()
-
isFailed
public boolean isFailed()
-
getDestination
public T getDestination()
-
getMouseMode
public MouseMode getMouseMode()
-
getMouseButton
public MouseButton getMouseButton()
-
getWheelMode
public WheelMode getWheelMode()
-
getWheelCondition
public Condition getWheelCondition()
-
getTimeout
public long getTimeout()
-
setCompleted
public void setCompleted(boolean completed)
-
setFailed
public void setFailed(boolean failed)
-
setDestination
public void setDestination(T destination)
-
setMouseMode
public void setMouseMode(MouseMode mouseMode)
-
setMouseButton
public void setMouseButton(MouseButton mouseButton)
-
setWheelMode
public void setWheelMode(WheelMode wheelMode)
-
setWheelCondition
public void setWheelCondition(Condition wheelCondition)
-
setTimeout
public void setTimeout(long timeout)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-