← 返回
内容创作

Screenshot Skill

Capture screenshots on Windows using mss and Pillow. Provides full-screen, region, and multi-monitor capture with output as PIL Image, PNG file, or base64 st...
使用 mss 和 Pillow 在 Windows 上截图。支持全屏、区域及多显示器捕获,输出格式包括 PIL Image、PNG 文件或 base64 字符串。
sunrddd-a11y
内容创作 clawhub v1.0.1 1 版本 99720.4 Key: 无需
★ 0
Stars
📥 1,783
下载
💾 71
安装
1
版本
#latest

概述

Screenshot Capture

基于 mss + Pillow 的高性能屏幕截图工具,适用于 Windows 桌面自动化、AI 视觉分析等场景。

依赖

uv add mss pillow
# 或
pip install mss pillow

快速开始

作为 Python 模块使用

from scripts.screenshot import ScreenCapture

with ScreenCapture() as sc:
    # 获取屏幕分辨率
    width, height = sc.screen_size

    # 全屏截图 → PIL Image
    img = sc.capture()

    # 截图保存为文件
    sc.capture_to_file("output.png")

    # 截图转 base64 (用于发送给视觉 API)
    b64 = sc.capture_to_base64(quality=85, fmt="JPEG")

作为 CLI 工具使用

# 查看显示器信息
python scripts/screenshot.py info

# 截图保存到文件
python scripts/screenshot.py capture -o my_screenshot.png

# 截图输出 base64
python scripts/screenshot.py base64 --format JPEG --quality 85

核心 API

方法说明返回值
--------------------
screen_size主显示器 (宽, 高)tuple[int, int]
all_screen_size虚拟全屏 (宽, 高),多屏合并tuple[int, int]
monitors所有显示器详细信息list[dict]
capture(monitor, region, delay)截图 → PIL ImageImage.Image
capture_to_file(filepath, ...)截图 → PNG/JPG 文件Path
capture_to_base64(quality, fmt, ...)截图 → base64 字符串str

常见场景

发送截图给 OpenAI 视觉 API

from openai import OpenAI
from scripts.screenshot import ScreenCapture

client = OpenAI()
with ScreenCapture() as sc:
    b64 = sc.capture_to_base64(fmt="JPEG", quality=85)

resp = client.chat.completions.create(
    model="gpt-4o",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "描述截图内容"},
            {"type": "image_url", "image_url": {
                "url": f"data:image/jpeg;base64,{b64}",
                "detail": "high",
            }},
        ],
    }],
)

截取指定区域

with ScreenCapture() as sc:
    region = {"left": 100, "top": 200, "width": 800, "height": 600}
    img = sc.capture(region=region)
    img.save("region.png")

自动保存每步截图

with ScreenCapture(save_dir="screenshots") as sc:
    for i in range(5):
        sc.capture_to_base64(step=i)  # 自动保存为 screenshots/step_000.jpg 等

详细参考

完整 API 参数说明见 reference.md

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-03-29 04:48 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

content-creation

Baidu Wenku AIPPT

ide-rea
使用百度文库 AI 智能生成 PPT,自动根据内容选择模板。
★ 66 📥 46,149
content-creation

AdMapix

fly0pants
广告情报与应用数据分析助手,支持搜索广告素材、分析应用排名、下载量、收入及市场洞察,用于广告素材和竞品分析。
★ 295 📥 136,438
content-creation

YouTube

byungkyu
使用托管OAuth集成YouTube Data API,支持搜索视频、管理播放列表、获取频道数据及评论互动,适用于用户需要时使用此技能。
★ 142 📥 41,034