{"id":24316,"library":"pydirectinput","title":"PyDirectInput","description":"A Python library for automating mouse and keyboard input on Windows using Direct Input (SendInput), bypassing limitations of pyautogui in DirectX games and applications. Current version: 1.0.4, updated 2021. No active development, but stable.","status":"maintenance","version":"1.0.4","language":"python","source_language":"en","source_url":"https://github.com/learncodebygaming/pydirectinput","tags":["automation","input","directinput","windows","game","keyboard","mouse"],"install":[{"cmd":"pip install pydirectinput","lang":"bash","label":"default"}],"dependencies":[{"reason":"Required for SendInput API calls","package":"pywin32","optional":false}],"imports":[{"note":"The module itself is the main entry point, not a class.","wrong":"from pydirectinput import PyDirectInput","symbol":"PyDirectInput","correct":"import pydirectinput"}],"quickstart":{"code":"import pydirectinput\nimport pyautogui\n\n# Move mouse relative (works in DirectX)\npydirectinput.moveRel(100, 0)\n\n# Click at current position\npydirectinput.click()\n\n# Type text\npydirectinput.write('Hello World', interval=0.1)\n\n# Press key\npydirectinput.press('enter')\n\n# Hold key\npydirectinput.keyDown('shift')\npydirectinput.keyUp('shift')","lang":"python","description":"Basic mouse and keyboard automation using direct input simulation. Note: PyDirectInput overrides pyautogui's functions, so you can use both together."},"warnings":[{"fix":"Use conditional imports: if sys.platform == 'win32': import pydirectinput","message":"PyDirectInput is Windows-only. It will fail on macOS or Linux with ImportError.","severity":"breaking","affected_versions":"all"},{"fix":"Consider using pynput for cross-platform needs; stick with PyDirectInput for DirectX game automation.","message":"The community fork 'pynput' or 'mouse' libraries may be preferred for cross-platform, but PyDirectInput remains best for DirectX games.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Test your input strings on a text field first. For special characters, map them to keys using keyDown/keyUp.","message":"PyDirectInput does not support all keyboard characters; complex Unicode or Korean/Japanese characters may not work. Use write() with ASCII characters only.","severity":"gotcha","affected_versions":"all"},{"fix":"Import pydirectinput after pyautogui if you want to override, or import pydirectinput as a separate namespace: import pydirectinput as di","message":"If you install both pyautogui and pydirectinput, pydirectinput will override pyautogui's functions globally. This can break code expecting pyautogui behavior.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"pip install pywin32","cause":"Missing dependency for SendInput API.","error":"ModuleNotFoundError: No module named 'pywin32'"},{"fix":"Ensure coordinates are positive integers and check screen size: from win32api import GetSystemMetrics; print(GetSystemMetrics(0), GetSystemMetrics(1))","cause":"Invalid mouse coordinates or button number passed to click() or moveRel(). Coordinates must be integers and within the screen bounds.","error":"OSError: [WinError 87] The parameter is incorrect."},{"fix":"Upgrade to latest: pip install --upgrade pydirectinput. Check version: pip show pydirectinput.","cause":"Outdated version (<1.0.0) or incorrect installation. Some attributes renamed.","error":"AttributeError: module 'pydirectinput' has no attribute 'moveRel'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}