AutoworkInputSender๏
Experimental: Some methods may not be implemented and may be changed in future versions.
Inherits: RefCounted < Object
Simulates input events for automated testing.
Description๏
The AutoworkInputSender provides utilities to simulate user input during tests.
It allows triggering input actions, keyboard events, and mouse interactions either globally or targeted at a specific Node.
This is useful for testing gameplay systems, UI interactions, and input-driven logic without requiring manual input.
Methods๏
void |
action_down(action: StringName, strength: float = 1.0, target: Node = null) |
void |
action_up(action: StringName, target: Node = null) |
void |
|
void |
|
void |
mouse_down(button_index: int, position: Vector2 = Vector2(0, 0), target: Node = null) |
void |
mouse_motion(position: Vector2, relative: Vector2 = Vector2(0, 0), target: Node = null) |
void |
mouse_up(button_index: int, position: Vector2 = Vector2(0, 0), target: Node = null) |
void |
Method Descriptions๏
void action_down(action: StringName, strength: float = 1.0, target: Node = null) ๐
Simulates an input action press.
The specified action is triggered as if it were pressed, with an optional strength value.
If target is provided, the event is sent directly to that node.
void action_up(action: StringName, target: Node = null) ๐
Simulates an input action release.
The specified action is released.
If target is provided, the event is sent directly to that node.
void key_down(keycode: int, target: Node = null) ๐
Simulates a key press event.
The given keycode is sent as a key down event.
If target is provided, the event is directed to that node.
sender.key_down(KEY_SPACE)
void key_up(keycode: int, target: Node = null) ๐
Simulates a key release event.
The given keycode is sent as a key up event.
If target is provided, the event is directed to that node.
sender.key_up(KEY_SPACE)
void mouse_down(button_index: int, position: Vector2 = Vector2(0, 0), target: Node = null) ๐
Simulates a mouse button press.
The specified mouse button_index is pressed at the given position.
If target is provided, the event is sent directly to that node.
sender.mouse_down(MOUSE_BUTTON_LEFT, Vector2(100, 100))
void mouse_motion(position: Vector2, relative: Vector2 = Vector2(0, 0), target: Node = null) ๐
Simulates mouse movement.
The cursor is moved to position, with an optional relative motion vector.
If target is provided, the event is directed to that node.
void mouse_up(button_index: int, position: Vector2 = Vector2(0, 0), target: Node = null) ๐
Simulates a mouse button release.
The specified mouse button_index is released at the given position.
If target is provided, the event is sent directly to that node.
sender.mouse_up(MOUSE_BUTTON_LEFT, Vector2(100, 100))
void reset_inputs() ๐
Resets all simulated input states.
This clears any active or "pressed" inputs previously triggered by the sender, ensuring a clean state for subsequent tests.