Skip to main content

A Windows-specific package for simulating keyboard and mouse inputs

Project description

WinDirectInput

WinDirectInput is born out of a desire to enhance and extend the capabilities left untouched by PyAutoGUI. It's a robust tool designed for developers and automation enthusiasts. This module excels in detecting key inputs and offers an improved screenshot functionality using mss, providing a faster alternative for real-time applications like object detection with OpenCV.

This module is a testament to innovation in automation, filling gaps and pushing the boundaries of what's possible in automated input control.

Installation

To start using WinDirectInput, simply install it via pip:

pip install WinDirectInput

After installation, you can import and use the module in your Python scripts:

import directinput

Dependencies

WinDirectInput thrives on the shoulders of powerful dependencies and requires Python 3.8 or higher. Key dependencies include:

  • opencv-python: For image processing and object detection integrations.
  • numpy: Essential for handling arrays and complex mathematical operations.
  • mss: The secret ingredient for lightning-fast screenshots.
  • pyscreeze, pyperclip: Supporting libraries enhancing the module's functionality.

Example Usage

Writing Complex Strings

import directinput

# Writing a string with special characters
directinput.write("Hello, world! 😃👍 #PythonRocks")

This demonstrates the enhanced write function, capable of handling a wide range of characters, surpassing limitations you might find in other modules.

Detecting Key Presses

import directinput

# Detect if the 'A' key is being pressed
if directinput.keyDetect('a'):
    print("The 'A' key is pressed!")

Locating an Image on the Screen

The locateImage function in WinDirectInput adds a layer of flexibility to image detection. Whether you're automating tasks based on visual cues or integrating with image processing, this function is incredibly handy.

import directinput

# Locate an image on the screen
point = directinput.locateImage("path_to_needle_image.png")

if point is not None:
    print(f"Image found at {point}")
else:
    print("Image not found")

Advanced Usage

  • locateImage comes with several parameters for refined control:
  • needleImage: Path to the image you want to find.
  • haystackImage: Path to the screenshot or image in which to search. If not provided, it captures the entire screen.
  • grayscale: Set to True for grayscale comparison, which can improve performance.
  • region: A specific region on the screen to search in.
  • threshold: The confidence level for image matching, allowing for slight variations.

This functionality is especially useful in scenarios where you need to interact with UI elements based on their appearance, or in cases where dynamic content changes the screen layout.

How Does It Work?

WinDirectInput is tailored for Windows 10 or higher systems, harnessing the underlying Windows API to deliver its functionalities. This specific design choice ensures compatibility and performance, particularly in how keyboard and mouse inputs are handled and how screenshots are captured and processed.

Your Contribution Matters

Your insights and contributions are pivotal to the evolution of WinDirectInput. Here's how you can get involved:

  • Report Bugs or Request Features: Encounter a bug or have an idea for a new feature? Open an issue on our GitHub page.
  • Code Contributions: Got a fix or enhancement? Submit a pull request to improve the codebase.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

WinDirectInput-1.0.3.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

WinDirectInput-1.0.3-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file WinDirectInput-1.0.3.tar.gz.

File metadata

  • Download URL: WinDirectInput-1.0.3.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for WinDirectInput-1.0.3.tar.gz
Algorithm Hash digest
SHA256 a86d4518ff17125f5677f6b0ff3e3d47314fd8ca472935f2d7670e3913ff3d03
MD5 1b75fe80f760fd0ffd7166b01e9e2b1d
BLAKE2b-256 c16c1282c2c6d5d26664981724a9894c75747ff3baa3c51db7ee6803afcad7a3

See more details on using hashes here.

File details

Details for the file WinDirectInput-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: WinDirectInput-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for WinDirectInput-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2bb9ad78e2603c572b9776548fe151d69ce1b6f09293e542d7128ff09eb7f600
MD5 447f09f99c2bef9775851fb93be43b0d
BLAKE2b-256 b365c12b603c8a98025be4654b60e46c7c1f4f16e7e22e7724a15fa22424fbac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page