PyDirectInput
Python mouse and keyboard input automation for Windows using Direct Input.
What it is and what it does
PyDirectInput provides mouse and keyboard input automation for Windows by using DirectInput scan codes and the SendInput() win32 function instead of the older Virtual Key Codes and deprecated mouse_event()/keybd_event() functions. This makes it suitable for automating input in applications that rely on DirectX, such as video games, where PyAutoGUI often fails. The package is designed as a drop-in replacement for PyAutoGUI's input functions—you can use both libraries together, substituting PyDirectInput only where PyAutoGUI doesn't work.
The library implements core input functions like moveTo(), click(), press(), keyDown(), keyUp(), and write(), but omits some PyAutoGUI features like scroll, drag, and hotkey functions. It has no external runtime dependencies and installs with low friction, but the project is abandoned: the last release was in February 2021 and the last commit in July 2023, so no maintenance or updates should be expected.
Use it for:
- Automate mouse and keyboard input in video games or DirectX applications where PyAutoGUI fails to register inputs.
- Create bots or automation scripts for Windows games that require direct input simulation rather than virtual key codes.
- Test game UI or input handling by programmatically simulating player mouse clicks and key presses.
- Build automation tools for Windows applications that ignore standard input APIs and require DirectInput.
- Supplement PyAutoGUI with DirectInput-based input for specific applications while keeping PyAutoGUI for other tasks.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Automates mouse and keyboard input on Windows using DirectInput scan codes and SendInput(), providing an alternative to PyAutoGUI that works in DirectX applications like video games.
Yes, but with caution. Install if you need DirectInput-based input automation for a Windows game or DirectX application where PyAutoGUI doesn't work, and you are comfortable maintaining the code yourself. The permissive MIT license and low install friction are positives. However, the abandoned status (no releases since 2021, last commit 2023) means no bug fixes, security updates, or compatibility work—you are on your own if issues arise with newer Windows or Python versions.
Install
pydirectinput on PyPI
pip
pip install pydirectinputuv
uv add pydirectinputpoetry
poetry add pydirectinputInstalling PyDirectInput
Before you install
Low install friction with no runtime dependencies. However, the package is abandoned—last release was 2021-02-02 and last commit 2023-07-04—so expect no maintenance, bug fixes, or compatibility updates for modern Python or Windows versions.
License in practice
MIT license (permissive) means you can use, modify, and distribute the package freely with minimal restrictions, though you must include the license notice.
Quickstart
pip install pydirectinput
import pydirectinput
pydirectinput.moveTo(100, 150)
pydirectinput.click()
pydirectinput.press('esc')
Windows only; requires Python 3.4 or later. DirectInput and SendInput are Windows-specific APIs, so this package will not work on macOS or Linux.
Verify before relying
- Whether the package works reliably with current Windows versions and modern Python 3.x releases, given the 2021 release date and 2023 last commit.
- Compatibility with recent DirectX versions and whether DirectInput scan codes remain stable across Windows updates.
- Whether pull requests are actually accepted and reviewed, despite the abandoned maintenance status.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.4) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 2,019 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 108,635/month — #12,548 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: PyDirectInput-1.0.4-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
PyAutoGUIPyAutoGUI programmatically controls the mouse…
permissive · top 5,000 on PyPI
pywinautoAutomate Microsoft Windows GUI interactions by…
permissive · top 5,000 on PyPI
PyAutoItPyAutoIt provides Python bindings to…
permissive · top 15,000 on PyPI
inputsProvides cross-platform Python access to…
permissive · top 15,000 on PyPI
keyboardHook global keyboard events, register hotkeys,…
permissive · top 5,000 on PyPI
pynputPynput lets you programmatically control and…
copyleft · top 5,000 on PyPI
pynput-robocorp-forkControls and monitors mouse and keyboard input…
copyleft · top 15,000 on PyPI
vncdotoolvncdotool is a command-line VNC client that…
permissive · top 15,000 on PyPI
MouseInfoMouseInfo displays the XY coordinates and RGB…
copyleft · top 5,000 on PyPI
pygletpyglet is a cross-platform windowing and…
unclear · top 5,000 on PyPI