Metadata-Version: 2.4
Name: rustautogui_py
Version: 0.1.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
License-File: LICENSE
Summary: 一个基于 **Rust + PyO3** 封装的高性能鼠标与键盘控制库，为 Python 提供了与人类操作无异的自动化输入功能。
Author-email: 潘明辉 <minghuip8@gmail.com>
License-Expression: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# rustautogui_py

一个基于 **Rust + PyO3** 封装的高性能鼠标与键盘控制库，  
为 Python 提供了与人类操作无异的自动化输入功能。  

本项目基于 [rustautogui](https://crates.io/crates/rustautogui) 实现，  
相比纯 Python 的 `pyautogui`，具有以下优势：

- 🚀 **性能更高**：底层使用 Rust 实现系统调用；
- 🧠 **更安全**：内存与线程安全；
- 🖱️ **功能全面**：支持鼠标移动、拖拽、滚轮、键盘输入、多键组合；
- 🧩 **Python 无缝集成**：通过 PyO3 封装，可直接在 Python 中调用。

---

## 🧰 安装

### 从 PyPI
```bash
pip install rustautogui_py
```
## 🧪 使用示例
```python
from rustautogui_py import MouseKeyBoardController
import time

gui = MouseKeyBoardController()

# 获取屏幕大小
w, h = gui.get_screen_size()
print(f"Screen: {w}x{h}")

# 获取当前鼠标位置
x, y = gui.get_mouse_position()
print(f"Mouse: ({x}, {y})")

# 移动鼠标到屏幕中央
gui.move_mouse_to_pos(w // 2, h // 2, 0.5)

# 执行点击
gui.left_click()
time.sleep(0.2)
gui.double_click()

# 模拟键盘输入
gui.keyboard_input("Hello Rust + Python!")
time.sleep(0.5)

# 组合键操作
gui.keyboard_multi_key("ctrl", "shift", "n")  # Ctrl+Shift+N
gui.keyboard_multi_key("ctrl", "c")           # Ctrl+C
gui.keyboard_multi_key("alt", "f4")           # Alt+F4
```
## 🖱️支持功能一览
| 方法名                                 | 功能说明          | 参数                                  | 返回值               |
| ----------------------------------- | ------------- | ----------------------------------- | ----------------- |
| `get_screen_size()`                 | 获取屏幕分辨率       | 无                                   | `(width, height)` |
| `get_mouse_position()`              | 获取鼠标坐标        | 无                                   | `(x, y)`          |
| `move_mouse_to_pos(x, y, duration)` | 将鼠标移动到指定坐标    | `x: u32`, `y: u32`, `duration: f32` | `None`            |
| `move_mouse(x, y, duration)`        | 相对移动鼠标        | `x: i32`, `y: i32`, `duration: f32` | `None`            |
| `drag_mouse_to_pos(x, y, duration)` | 拖拽至指定坐标       | 同上                                  | `None`            |
| `drag_mouse(x, y, duration)`        | 拖拽至相对偏移       | 同上                                  | `None`            |
| `click(button)`                     | 点击鼠标键         | `"left"`, `"right"`, `"middle"`     | `None`            |
| `click_down(button)`                | 按下鼠标键         | 同上                                  | `None`            |
| `click_up(button)`                  | 释放鼠标键         | 同上                                  | `None`            |
| `left_click()`                      | 左键单击          | 无                                   | `None`            |
| `right_click()`                     | 右键单击          | 无                                   | `None`            |
| `double_click()`                    | 左键双击          | 无                                   | `None`            |
| `middle_click()`                    | 中键点击          | 无                                   | `None`            |
| `scroll_up(intensity)`              | 向上滚动滚轮        | `intensity: u32`                    | `None`            |
| `scroll_down(intensity)`            | 向下滚动滚轮        | `intensity: u32`                    | `None`            |
| `scroll_left(intensity)`            | 向左滚动          | `intensity: u32`                    | `None`            |
| `scroll_right(intensity)`           | 向右滚动          | `intensity: u32`                    | `None`            |
| `key_down(key)`                     | 按下键盘按键        | `key: str`                          | `None`            |
| `key_up(key)`                       | 松开键盘按键        | `key: str`                          | `None`            |
| `keyboard_input(str)`               | 输入字符串         | `str: &str`                         | `None`            |
| `keyboard_command(command)`         | 特殊命令（如回车、ESC） | `command: &str`                     | `None`            |
| `keyboard_multi_key(args)`          | 同时按下多个按键      | `["ctrl", "shift", "n"]`            | `None`            |









