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 ofAbstractMouseDestinationthat you need. These examples usePointDestinationExamples: 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 ofAbstractMouseDestinationMouseEvent(T destination, MouseMode mouseMode, MouseButton mouseButton)Moves the mouse to the givenAbstractMouseDestinationif given one, does not move if null IfMouseModeis notMouseMode.NONEit 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 Conditioncompleted()AbstractConditionused to determine if current event is complete.booleanequals(java.lang.Object o)Conditionfailed()AbstractConditionused to determine if current event has failed.TgetDestination()MouseButtongetMouseButton()MouseModegetMouseMode()longgetTimeout()ConditiongetWheelCondition()WheelModegetWheelMode()inthashCode()booleanisCompleted()booleanisFailed()voidrun()Runs the event.voidsetCompleted(boolean completed)voidsetDestination(T destination)voidsetFailed(boolean failed)voidsetMouseButton(MouseButton mouseButton)voidsetMouseMode(MouseMode mouseMode)voidsetTimeout(long timeout)voidsetWheelCondition(Condition wheelCondition)voidsetWheelMode(WheelMode wheelMode)java.lang.StringtoString()
-
-
-
Constructor Detail
-
MouseEvent
public MouseEvent(T destination)
Moves the mouse to the given destination Does not Click See implementations ofAbstractMouseDestination- Parameters:
destination-AbstractMouseDestinationto use to move the mouse
-
MouseEvent
public MouseEvent(T destination, MouseMode mouseMode, MouseButton mouseButton)
Moves the mouse to the givenAbstractMouseDestinationif given one, does not move if null IfMouseModeis notMouseMode.NONEit 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-AbstractMouseDestinationto use to move the mouse - if not null will assume mouse movementmouseMode-MouseModemouse mode to determine the event types to use if it's not a basic move call. IfMouseMode.NONE, only does regular move events. SeeMoveEventmouseButton-MouseButtonbutton 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-AbstractMouseDestinationto use to move the mouse - if not null will assume mouse movementmouseMode-MouseModemouse mode to determine the event types to use if it's not a basic move call. IfMouseMode.NONE, only does regular move events. SeeMoveEventwheelMode-WheelModefor scrolling up or downstop-Conditionfor 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.DRAGwe 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()
AbstractConditionused to determine if current event is complete.- Overrides:
completedin classAbstractMouseEvent- Returns:
Conditionused to determine if current event has completed successfully.
-
failed
public Condition failed()
AbstractConditionused to determine if current event has failed.- Overrides:
failedin classAbstractMouseEvent- Returns:
Conditionused 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-