Input Functions

class autocv.core.input.Input(hwnd: int = -1)[source]

Bases: Vision

Extends the Vision class with functionalities for simulating user input.

This class supports human-like mouse movements, clicks, and keyboard key presses. Randomness and delays are incorporated to mimic natural interaction.

get_last_moved_point() tuple[int, int][source]

Returns the last point where the mouse cursor was moved.

Returns:

Last cursor position that was targeted.

Return type:

tuple[int, int]

move_mouse(x: int, y: int, *, human_like: bool = True, ghost_mouse: bool = True) None[source]

Moves the mouse cursor to the specified (x, y) coordinates.

The movement is relative to the client area of the target window. If human_like is True, the movement will simulate natural motion.

Parameters:
  • x (int) – Target x-coordinate inside the client area.

  • y (int) – Target y-coordinate inside the client area.

  • human_like (bool) – When True, simulate human-like mouse motion.

  • ghost_mouse (bool) – When True, rely on ghost mouse behaviour; otherwise emit OS cursor updates.

click_mouse(button: int = 1, *, send_message: bool = False) None[source]

Simulates a mouse click at the last moved position.

Parameters:
  • button (int) – Mouse button identifier (1=left, 2=right, 3=middle).

  • send_message (bool) – When True, dispatches SendMessage instead of PostMessage.

press_vk_key(vk_code: int) None[source]

Simulates pressing a virtual key.

Parameters:

vk_code (int) – Virtual-key code to press.

release_vk_key(vk_code: int) None[source]

Simulates releasing a virtual key.

Parameters:

vk_code (int) – Virtual-key code to release.

send_vk_key(vk_code: int) None[source]

Sends a virtual key by simulating a press and release.

Parameters:

vk_code (int) – Virtual-key code to send.

static get_async_key_state(vk_code: int) bool[source]

Retrieves the asynchronous state of a specified virtual key.

Parameters:

vk_code (int) – Virtual-key code tested via GetAsyncKeyState.

Returns:

True if the key was pressed since the previous poll, otherwise False.

Return type:

bool

send_keys(characters: str) None[source]

Sends a sequence of keystrokes to the active window.

Parameters:

characters (str) – Characters to emit sequentially.