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:
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:
Clear Purpose: Solves a specific, common use case
Well Documented: Comments explaining what each part does
Error Handling: Proper exception handling
Performance: Optimized for its use case
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๏
๐ Browse Examples: Pick your use case from the list above
๐ป Try the Code: Copy and run examples locally
๐ง Adapt for Your Needs: Modify examples for your specific requirements
๐ Build Something Cool: Use examples as starting points for your projects
๐ค Share Back: Contribute your own examples to help others!