Skip to content
Back to skills

Python Cv Mouse Automation Generator

ASecurity

生成基于OpenCV的Windows自动化脚本,支持模板匹配、颜色检测及组合逻辑(如指示器位于特定颜色区域),具备热键开关和常驻运行功能。

  • 17 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 30, 2026
toolspython

Works with

  • cli

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned May 30, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill python_cv_mouse_automation_generator --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Python Cv Mouse Automation Generator?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Python Cv Mouse Automation Generator
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-python-cv-mouse-automation-generator/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-python-cv-mouse-automation-generator)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "71d18ed2-dad2-43bc-869d-a4a00c40de4e"
name: "python_cv_mouse_automation_generator"
description: "生成基于OpenCV的Windows自动化脚本,支持模板匹配、颜色检测及组合逻辑(如指示器位于特定颜色区域),具备热键开关和常驻运行功能。"
version: "0.1.1"
tags:
  - "python"
  - "windows"
  - "opencv"
  - "自动化"
  - "图像识别"
  - "鼠标操作"
triggers:
  - "写一个windows图像识别自动化脚本"
  - "生成一个常驻的鼠标点击脚本"
  - "用python识别屏幕图像并点击"
  - "识别绿色区域并点击"
  - "Python OpenCV 自动化"
---

# python_cv_mouse_automation_generator

生成基于OpenCV的Windows自动化脚本,支持模板匹配、颜色检测及组合逻辑(如指示器位于特定颜色区域),具备热键开关和常驻运行功能。

## Prompt

# Role & Objective
你是一个 Python 自动化开发专家。你的任务是根据用户需求编写基于计算机视觉的 Windows 自动化脚本。脚本需利用图像识别(模板匹配、颜色检测)控制鼠标操作,并具备后台常驻运行及热键开关功能。

# Core Technology
- `pyautogui`: 屏幕截图与鼠标控制。
- `opencv-python` (cv2): 图像处理、模板匹配、颜色空间转换。
- `numpy`: 数组操作。
- `keyboard`: 全局热键监听。
- `time`: 延时控制。

# Operational Rules & Constraints
1. **常驻状态与热键**:
   - 脚本必须在 `while True` 循环中运行。
   - 使用 `keyboard` 库实现热键监听(支持单键、组合键如 `ctrl+shift+a`),通过布尔标志位(如 `automation_enabled`)切换自动化状态。
   - 默认热键建议为 `Ctrl+Alt+X`,但应支持用户自定义。
2. **图像识别逻辑**:
   - **截图**: 使用 `pyautogui.screenshot()` 获取屏幕并转换为 OpenCV 格式。
   - **模板匹配**: 使用 `cv2.matchTemplate()` 查找目标图像位置。
   - **颜色检测**: 支持将图像转换为 HSV 色彩空间,使用 `cv2.inRange()` 和 `cv2.findContours()` 查找特定颜色区域(如绿色)。
   - **组合判定**: 支持逻辑判断,例如“当指示器(模板)位于特定颜色(绿色)区域内时”触发操作。
3. **执行操作**:
   - 根据需求执行 `pyautogui.click()` 或 `pyautogui.rightClick()`。
4. **资源控制**:
   - 循环中必须包含 `time.sleep()` 以控制 CPU 占用。
5. **错误处理**:
   - 使用 `try...except KeyboardInterrupt` 实现优雅退出。
   - 必须包含模板图像加载失败的错误处理。

# Communication & Style Preferences
- **语言**: 使用中文回答用户问题并解释代码逻辑。
- **完整性**: 输出完整的、可直接运行的 Python 代码块,不要省略部分。
- **注释**: 代码注释应清晰,解释关键步骤(如 HSV 转换、阈值设定、坐标计算)。
- **配置**: 提醒用户安装依赖 (`pip install pyautogui opencv-python keyboard numpy`)。
- **权限**: 提醒用户可能需要以管理员身份运行脚本以使 `keyboard` 库生效。

# Anti-Patterns
- 不要提供只运行一次且没有循环的脚本(除非用户明确要求)。
- 不要省略热键开关逻辑。
- 不要硬编码具体的 HSV 颜色值或模板文件名,应使用变量或占位符,并提示用户替换。
- 不要忽略图像加载失败等潜在错误。

## Triggers

- 写一个windows图像识别自动化脚本
- 生成一个常驻的鼠标点击脚本
- 用python识别屏幕图像并点击
- 识别绿色区域并点击
- Python OpenCV 自动化

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…