Examples๏ƒ

This section contains practical examples for common use cases with the Makcu library. Each example includes both synchronous and asynchronous versions where applicable.

Quick Start Examples๏ƒ

Here are some quick examples to get you started:

Basic Mouse Control๏ƒ

from makcu import create_controller, MouseButton

# Simple click and move
makcu = create_controller()
makcu.click(MouseButton.LEFT)
makcu.move(100, 50)
makcu.disconnect()

Async Version๏ƒ

import asyncio
from makcu import create_async_controller, MouseButton

async def main():
    async with await create_async_controller() as makcu:
        await makcu.click(MouseButton.LEFT)
        await makcu.move(100, 50)

asyncio.run(main())

Gaming Example๏ƒ

from makcu import create_controller, MouseButton

makcu = create_controller(debug=False)  # Max performance

# Ultra-fast gaming clicks
makcu.click_human_like(MouseButton.LEFT, profile="gaming")

# Precise movement
makcu.move_smooth(200, 100, segments=30)

Choose Your Use Case๏ƒ

๐ŸŽฎ Gaming Applications

High-performance mouse control for competitive gaming, with sub-3ms response times and parallel operations.

โ†’ See: gaming_applications, high_performance_gaming

๐Ÿค– Automation Scripts

Automate repetitive tasks with human-like mouse movements and intelligent timing.

โ†’ See: automation_scripts, human_like_interactions

๐ŸŒ Web Applications

Integrate mouse control into web servers, APIs, and online services.

โ†’ See: web_integration, fastapi_web_app

๐Ÿ’ฌ Discord/Chat Bots

Add mouse control commands to Discord bots and chat applications.

โ†’ See: discord_bot

๐Ÿ–ฅ๏ธ GUI Applications

Embed mouse control into desktop applications with proper async integration.

โ†’ See: gui_applications

โšก High Performance

Maximize performance for real-time applications requiring minimal latency.

Performance Comparison๏ƒ

Hereโ€™s how different approaches perform:

Performance by Use Case๏ƒ

Use Case

Sync Performance

Async Performance

Best For

Gaming

~2ms per operation

~1ms per operation

Real-time gaming

Automation

~5ms per operation

~3ms per operation

Scripts & bots

Web Apps

Blocking

Non-blocking

Server applications

Bulk Operations

Sequential

Parallel

Large datasets

Code Standards๏ƒ

All examples follow these standards:

  • โœ… Error Handling: Proper exception handling

  • โœ… Resource Cleanup: Context managers and proper disconnection

  • โœ… Type Hints: Full type annotations for clarity

  • โœ… Documentation: Detailed comments and docstrings

  • โœ… Performance: Optimized for their specific use case

  • โœ… Modern Python: Uses Python 3.7+ features and best practices

Running Examples๏ƒ

Each example can be run directly:

# Download example
curl -O https://raw.githubusercontent.com/SleepyTotem/makcu-py-lib/main/examples/basic_mouse_control.py

# Run example
python basic_mouse_control.py

Or integrated into your own projects:

# Import and adapt
from examples.gaming_applications import gaming_combo

# Use in your code
await gaming_combo()

Contributing Examples๏ƒ

Have a great example to share? Weโ€™d love to include it!

Example Requirements:

  1. Clear Purpose: Solves a specific, common use case

  2. Well Documented: Comments explaining what each part does

  3. Error Handling: Proper exception handling

  4. Performance: Optimized for its use case

  5. Both Versions: Include sync and async versions if applicable

Submit via:

  • GitHub Pull Request to the examples/ directory

  • GitHub Discussions with your code

  • GitHub Issues tagged as โ€œexample requestโ€

Next Steps๏ƒ

  1. ๐Ÿ“– Browse Examples: Pick your use case from the list above

  2. ๐Ÿ’ป Try the Code: Copy and run examples locally

  3. ๐Ÿ”ง Adapt for Your Needs: Modify examples for your specific requirements

  4. ๐Ÿš€ Build Something Cool: Use examples as starting points for your projects

  5. ๐Ÿค Share Back: Contribute your own examples to help others!