Input Functions

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

Bases: Vision

Simulate mouse and keyboard input for a target window handle.

The class extends Vision with helpers that post and send Win32 messages for mouse movement, clicks, and keystrokes.

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

Return the last client-area point targeted by move_mouse().

Returns:

The most recent (x, y) point in client coordinates.

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

Move the mouse cursor to (x, y) in client coordinates.

Parameters:
  • x – Target X coordinate inside the window client area.

  • y – Target Y coordinate inside the window client area.

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

  • ghost_mouse – When True, simulate motion using Win32 messages; when False, move the OS cursor.

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

Click a mouse button at the last moved position.

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

  • send_message – When True, use SendMessage instead of PostMessage for the click.

press_vk_key(vk_code: int) None[source]

Press a virtual key using Win32 keyboard messages.

Parameters:

vk_code – Virtual-key code (VK_*) to press.

Notes

This method sends WM_CHAR with chr(vk_code) to preserve historical behaviour.

release_vk_key(vk_code: int) None[source]

Release a virtual key using Win32 keyboard messages.

Parameters:

vk_code – Virtual-key code (VK_*) to release.

send_vk_key(vk_code: int) None[source]

Send a virtual key by pressing and releasing it.

Parameters:

vk_code – Virtual-key code (VK_*) to send.

static get_async_key_state(vk_code: int) bool[source]

Return the asynchronous state of a specified virtual key.

Parameters:

vk_code – Virtual-key code tested via GetAsyncKeyState.

Returns:

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

send_keys(characters: str) None[source]

Send a sequence of characters to the target window.

Parameters:

characters – Characters to emit sequentially.