Skip to main content

No project description provided

Project description

KeyGenie

鼠标和键盘操作录制工具,自动生成可执行的Python代码。

安装与使用

方式1:使用 uvx(推荐,无需安装)

无需安装,直接运行:

# 录制
uvx keygenie record

# 回放
uvx keygenie replay

# 带参数
uvx keygenie record -d /path/to/save
uvx keygenie replay /path/to/record.py

方式2:传统安装后使用

先安装包,然后使用 kg 命令:

# 先安装
pip install keygenie

# 或
uv pip install keygenie

# 然后使用
kg record
kg replay

开发模式安装

如果你想从源码开发或修改:

# 使用uv安装(推荐)
uv sync
uv pip install -e .

# 或使用pip
pip install -e .

使用

开始录制

kg record

# 指定保存目录
kg record -d /path/to/save

录制过程中执行操作,按 Ctrl+C 或按 q 键结束录制。

输出文件

录制完成后会在指定目录(默认 ./keygenie_records/)生成:

  • record.py - 可执行的Python代码
  • record.md - 包含代码和截图的Markdown文档
  • screenshots/ - 截图文件夹

回放录制的操作

# 回放最近一次录制
kg replay

# 回放指定的文件
kg replay /path/to/record.py

# 在指定目录中查找并回放最新录制
kg replay -d /custom/path

回放时支持安全机制:

  • 按下 ESC 键可立即停止回放
  • 鼠标移动到屏幕边缘时会自动停止回放

运行生成的代码

你也可以直接运行生成的 Python 文件:

python path/to/record.py

功能特性

  • 录制鼠标点击、拖拽、滚动操作
  • 录制键盘输入和快捷键
  • 自动保存点击位置截图
  • 生成带像素验证的安全点击代码
  • 自动生成Markdown文档
  • 一键回放录制的操作
  • 回放时支持安全停止机制(ESC键或屏幕边缘检测)
  • 跨平台键盘映射支持(Mac 上正确识别 Command 键)

系统要求

  • Python >= 3.10
  • macOS / Linux
  • macOS需要授予辅助功能权限(系统设置 → 隐私与安全性 → 辅助功能)

项目结构

keygenie/
├── cli.py              # 命令行接口
├── constant.py         # 常量定义
├── recoder/            # 录制模块
│   └── recorder.py     # 主录制器
├── runner/             # 运行模块
│   └── mouse/
│       └── mouse_operator.py  # 鼠标操作器
└── utils/              # 工具模块
    └── decorator.py    # 装饰器

示例

生成的代码示例:

import pyautogui
from keygenie.runner.mouse.mouse_operator import MouseOperator

mouse_operator = MouseOperator()

mouse_operator.safe_click(219, 54, pixel=(237, 232, 215), tolerance=10)
# Mac 上会生成 'command',其他平台会生成 'ctrl'
pyautogui.hotkey('command', 'c')  # macOS
# pyautogui.hotkey('ctrl', 'c')    # Linux/Windows
mouse_operator.drag(100, 100, to_x=200, to_y=200)

键盘映射

  • macOS: cmd 键映射为 commandalt 键映射为 option
  • Linux/Windows: cmd 键映射为 ctrlalt 键映射为 alt

系统会自动根据运行平台生成正确的键盘映射代码。

许可证

MIT License

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

keygenie-0.0.1.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

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

keygenie-0.0.1-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file keygenie-0.0.1.tar.gz.

File metadata

  • Download URL: keygenie-0.0.1.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for keygenie-0.0.1.tar.gz
Algorithm Hash digest
SHA256 127daef862685544877f37b91af014ce8a14e7f3db5871aac92ea53069f01168
MD5 fbca96f22623548620a4eb07e16449d9
BLAKE2b-256 9bc21d3a0c89a775e8188f38c8335baa0c14174088bef2eff8c84538e9a0a8c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for keygenie-0.0.1.tar.gz:

Publisher: release.yml on sijicuisite/MouseKeyboardRecorder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file keygenie-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: keygenie-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for keygenie-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 48788a738d54a0fc4e083334d62b275cde1a1e6c6b8c0b7a5bd7106d469d0adc
MD5 b8e7a37368643fb247d810c9bb59dd85
BLAKE2b-256 50ff89e1e2edc3f3c7581bba07649a13be750000d4e4c21a3f2bcfd995cf3d9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for keygenie-0.0.1-py3-none-any.whl:

Publisher: release.yml on sijicuisite/MouseKeyboardRecorder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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